1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 13:54:03 +00:00

Fix storage_path() and asset()

This commit is contained in:
Samuel Štancl 2019-01-19 23:11:15 +01:00
parent bad6ea4641
commit 8f384ade12

View file

@ -4,6 +4,8 @@ namespace Stancl\Tenancy;
trait BootstrapsTenancy trait BootstrapsTenancy
{ {
public $oldstoragepaths;
public function bootstrap() public function bootstrap()
{ {
$this->switchDatabaseConnection(); $this->switchDatabaseConnection();
@ -36,11 +38,31 @@ trait BootstrapsTenancy
public function suffixFilesystemRootPaths() public function suffixFilesystemRootPaths()
{ {
$old = [
"storage_disks" => [],
"storage_path" => $this->app->storagePath,
"asset" => asset(''),
];
$suffix = $this->app['config']['tenancy.filesystem.suffix_base'] . tenant('uuid'); $suffix = $this->app['config']['tenancy.filesystem.suffix_base'] . tenant('uuid');
// Storage facade
foreach ($this->app['config']['tenancy.filesystem.disks'] as $disk) { foreach ($this->app['config']['tenancy.filesystem.disks'] as $disk) {
$root = $this->app['config']["filesystems.disks.{$disk}.root"];
\Storage::disk($disk)->getAdapter()->setPathPrefix( \Storage::disk($disk)->getAdapter()->setPathPrefix(
$this->app['config']["filesystems.disks.{$disk}.root"] . "/{$suffix}" $root . "/{$suffix}"
); );
$old['storage_disks'][$disk] = $root;
} }
// storage_path()
$this->app->useStoragePath($this->app->storagePath() . $path);
// asset()
$this->app('url')->forceRootUrl(asset('') . $url);
$this->oldStoragePaths = $old;
} }
} }