mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 17:04:04 +00:00
Fix storage_path() and asset()
This commit is contained in:
parent
bad6ea4641
commit
8f384ade12
1 changed files with 23 additions and 1 deletions
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue