mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-13 00:14:04 +00:00
asset() tenancy
This commit is contained in:
parent
cf71fa5979
commit
6134c8113b
5 changed files with 27 additions and 7 deletions
|
|
@ -9,8 +9,6 @@ use Illuminate\Support\Facades\Storage;
|
|||
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
||||
use Stancl\Tenancy\Tenant;
|
||||
|
||||
// todo2 better solution than tenant_asset?
|
||||
|
||||
class FilesystemTenancyBootstrapper implements TenancyBootstrapper
|
||||
{
|
||||
protected $originalPaths = [];
|
||||
|
|
@ -24,17 +22,21 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper
|
|||
$this->originalPaths = [
|
||||
'disks' => [],
|
||||
'path' => $this->app->storagePath(),
|
||||
'asset' => $this->app['config']['asset_url'],
|
||||
];
|
||||
}
|
||||
|
||||
public function start(Tenant $tenant)
|
||||
{
|
||||
// todo2 revisit this
|
||||
$suffix = $this->app['config']['tenancy.filesystem.suffix_base'] . $tenant->id;
|
||||
|
||||
// storage_path()
|
||||
$this->app->useStoragePath($this->originalPaths['path'] . "/{$suffix}");
|
||||
|
||||
// asset()
|
||||
$this->app['config']['app.asset_url'] = ($this->originalPaths['asset'] ?? $this->app['config']['app.url']) . "/$suffix";
|
||||
$this->app['url']->setAssetRoot($this->app['config']['app.asset_url']);
|
||||
|
||||
// Storage facade
|
||||
foreach ($this->app['config']['tenancy.filesystem.disks'] as $disk) {
|
||||
$this->originalPaths['disks'][$disk] = Storage::disk($disk)->getAdapter()->getPathPrefix();
|
||||
|
|
@ -54,6 +56,10 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper
|
|||
// storage_path()
|
||||
$this->app->useStoragePath($this->originalPaths['path']);
|
||||
|
||||
// asset()
|
||||
$this->app['config']['app.asset_url'] = $this->originalPaths['asset'];
|
||||
$this->app['url']->setAssetRoot($this->app['config']['app.asset_url']);
|
||||
|
||||
// Storage facade
|
||||
foreach ($this->app['config']['tenancy.filesystem.disks'] as $disk) {
|
||||
Storage::disk($disk)->getAdapter()->setPathPrefix($this->originalPaths['disks'][$disk]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue