From ba59f79192bd3ace0c1d97e7b4145962b8820462 Mon Sep 17 00:00:00 2001 From: Chris Brown Date: Mon, 23 Sep 2019 17:33:41 -0400 Subject: [PATCH 1/2] Update filesystem-tenancy.blade.md --- docs/source/v2/filesystem-tenancy.blade.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/docs/source/v2/filesystem-tenancy.blade.md b/docs/source/v2/filesystem-tenancy.blade.md index dcf46f1..ba6fcb1 100644 --- a/docs/source/v2/filesystem-tenancy.blade.md +++ b/docs/source/v2/filesystem-tenancy.blade.md @@ -13,7 +13,16 @@ The `storage_path()` will be suffixed with a directory named `config('tenancy.fi The root of each disk listed in `tenancy.filesystem.disks` will be suffixed with `config('tenancy.filesystem.suffix_base') . $id`. -**However, this alone would cause unwanted behavior.** It would work for S3 and similar disks, but for local disks, this would result in `/path_to_your_application/storage/app/tenant1e22e620-1cb8-11e9-93b6-8d1b78ac0bcd/`. That's not what we want. We want `/path_to_your_application/storage/tenant1e22e620-1cb8-11e9-93b6-8d1b78ac0bcd/app/`. Why? Because `storage_path()` returns `/path_to_your_application/storage/tenant1e22e620-1cb8-11e9-93b6-8d1b78ac0bcd/`, so `storage_path('app') means appending `app` to that. +**However, this alone would cause unwanted behavior.** It would work for S3 and similar disks, but for local disks Laravel does its own suffixing. For local storage we need the second of these examples: +``` +/path_to_your_application/storage/app/tenant1e22e620-1cb8-11e9-93b6-8d1b78ac0bcd/ +/path_to_your_application/storage/tenant1e22e620-1cb8-11e9-93b6-8d1b78ac0bcd/app/ +``` +Why? Because `storage_path()` returns: + +`/path_to_your_application/storage/tenant1e22e620-1cb8-11e9-93b6-8d1b78ac0bcd/` + +so Laravel's `storage_path('app')` means appending `app` to that. That's what the `root_override` section is for. `%storage_path%` gets replaced by `storage_path()` *after* tenancy has been initialized. The roots of disks listed in the `root_override` section of the config will be replaced accordingly. All other disks will be simply suffixed with `tenancy.filesystem.suffix_base` + the tenant id. @@ -23,18 +32,18 @@ Since `storage_path()` will be suffixed, your folder structure will look like th 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()`. +Logs will be saved to `storage/logs` regardless of any changes to `storage_path()`, and regardless of tenant. ## Assets {#assets} -The `asset()` helper has two different paths of execution: +Laravel's `asset()` helper has two different paths of execution: - If `config('app.asset_url')` has been set, it will simply append `tenant$id` to the end of the configured asset URL. This is useful if you use Laravel Vapor. Vapor sets the asset URL to something like `https://abcdefghijkl.cloudfrount.net/123-456-789`. That is the root for your assets. This package will append that with something like `tenant1e22e620-1cb8-11e9-93b6-8d1b78ac0bcd`. - If `config('app.asset_url')` is null, as it is by default, the helper will return a URL (`/tenancy/assets/...`) to a controller provided by this package. That controller returns a file response from `storage_path("app/public/$path")`. This means that you need to store your assets in the public directory. > Note: In 1.x, the `asset()` helper was not tenant-aware, and there was a `tenant_asset()` helper that followed the second option in the list above (a link to a controller). For backwards compatibility, that helper remains intact. -> If you have some non-tenant-specific assets, you may use the `global_asset()` helper. +> If you have some non-tenant-specific assets, you may use Tenancy's `global_asset()` helper. Note that all tenant assets have to be in the `app/public/` subdirectory of the tenant's storage directory, as shown in the image above. From 376144bd42deead0aaec4557ace6bbda681d2acb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Tue, 24 Sep 2019 16:11:25 +0200 Subject: [PATCH 2/2] Update filesystem-tenancy.blade.md --- docs/source/v2/filesystem-tenancy.blade.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/v2/filesystem-tenancy.blade.md b/docs/source/v2/filesystem-tenancy.blade.md index ba6fcb1..3b19377 100644 --- a/docs/source/v2/filesystem-tenancy.blade.md +++ b/docs/source/v2/filesystem-tenancy.blade.md @@ -43,7 +43,7 @@ Laravel's `asset()` helper has two different paths of execution: > Note: In 1.x, the `asset()` helper was not tenant-aware, and there was a `tenant_asset()` helper that followed the second option in the list above (a link to a controller). For backwards compatibility, that helper remains intact. -> If you have some non-tenant-specific assets, you may use Tenancy's `global_asset()` helper. +> If you have some non-tenant-specific assets, you may use the pakage's `global_asset()` helper. Note that all tenant assets have to be in the `app/public/` subdirectory of the tenant's storage directory, as shown in the image above.