mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 12:54:05 +00:00
Merge branch 'master' of https://github.com/stancl/tenancy
This commit is contained in:
commit
48baf88bf3
2 changed files with 22 additions and 4 deletions
25
README.md
25
README.md
|
|
@ -4,12 +4,14 @@
|
||||||
|
|
||||||
### *A Laravel multi-database tenancy implementation that respects your code.*
|
### *A Laravel multi-database tenancy implementation that respects your code.*
|
||||||
|
|
||||||
You won't have to change a thing in your application's code.
|
You won't have to change a thing in your application's code.\*
|
||||||
|
|
||||||
- :white_check_mark: No model traits to change database connection
|
- :white_check_mark: No model traits to change database connection
|
||||||
- :white_check_mark: No replacing of Laravel classes (`Cache`, `Storage`, ...) with tenancy-aware classes
|
- :white_check_mark: No replacing of Laravel classes (`Cache`, `Storage`, ...) with tenancy-aware classes
|
||||||
- :white_check_mark: Built-in tenant identification based on hostname
|
- :white_check_mark: Built-in tenant identification based on hostname
|
||||||
|
|
||||||
|
\* depending on how you use the filesystem. Be sure to read [that section](#filesystemstorage). Everything else will work out of the box.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
### Installing the package
|
### Installing the package
|
||||||
|
|
@ -127,7 +129,7 @@ config('tenancy.filesystem.suffix_base') . $uuid
|
||||||
|
|
||||||
These changes will only apply for disks listen in `disks`.
|
These changes will only apply for disks listen in `disks`.
|
||||||
|
|
||||||
You can see an example in the [Filesystem](#Filesystem) section of the documentation.
|
You can see an example in the [Filesystem](#filesystemstorage) section of the documentation.
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
|
||||||
|
|
@ -314,7 +316,7 @@ Connections listed in the `tenancy.redis.prefixed_connections` config array use
|
||||||
Both `cache()` and `Cache` will use `Stancl\Tenancy\CacheManager`, which adds a tag (`prefix_base` + tenant UUID) to all methods called on it.
|
Both `cache()` and `Cache` will use `Stancl\Tenancy\CacheManager`, which adds a tag (`prefix_base` + tenant UUID) to all methods called on it.
|
||||||
|
|
||||||
|
|
||||||
## Filesystem
|
## Filesystem/Storage
|
||||||
|
|
||||||
Assuming the following tenancy config:
|
Assuming the following tenancy config:
|
||||||
|
|
||||||
|
|
@ -343,6 +345,23 @@ The `local` filesystem driver will be suffixed with a directory containing `tena
|
||||||
=> "/var/www/laravel/multitenancy/storage/app/tenantdbe0b330-1a6e-11e9-b4c3-354da4b4f339/"
|
=> "/var/www/laravel/multitenancy/storage/app/tenantdbe0b330-1a6e-11e9-b4c3-354da4b4f339/"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
`storage_path()` will also be suffixed in the same way. Note that this means that each tenant will have their own storage directory.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
If you write to these directories, you will need to create them after you create the tenant. See the docs for [PHP's mkdir](http://php.net/function.mkdir).
|
||||||
|
|
||||||
|
Logs will be saved to `storage/logs` regardless of any changes to `storage_path()`.
|
||||||
|
|
||||||
|
One thing that you **will** have to change if you use storage similarly to the example on the image is your use of the helper function `asset()` (that is, if you use it).
|
||||||
|
|
||||||
|
You need to make this change to your code:
|
||||||
|
|
||||||
|
```diff
|
||||||
|
- asset("storage/images/products/$product_id.png");
|
||||||
|
+ tenant_asset("images/products/$product_id.png");
|
||||||
|
```
|
||||||
|
|
||||||
## Artisan commands
|
## Artisan commands
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ class TenantAssetController extends Controller
|
||||||
try {
|
try {
|
||||||
return response()->file(storage_path('app/public/' . $path));
|
return response()->file(storage_path('app/public/' . $path));
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
dd(storage_path('app/public/' . $path));
|
|
||||||
abort(404);
|
abort(404);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue