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

Fix a lot of bugs, fix #23

This commit is contained in:
Samuel Štancl 2019-02-08 22:44:46 +01:00
parent 39d9c9d51e
commit 22fc843ce3
10 changed files with 88 additions and 23 deletions

View file

@ -4,7 +4,7 @@ namespace Stancl\Tenancy\Controllers;
use Illuminate\Routing\Controller;
class TenantAssetController extends Controller
class TenantAssetsController extends Controller
{
public function __construct()
{

View file

@ -4,6 +4,7 @@ namespace Stancl\Tenancy\Traits;
use Stancl\Tenancy\CacheManager;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\Storage;
trait BootstrapsTenancy
{
@ -47,20 +48,22 @@ trait BootstrapsTenancy
$suffix = $this->app['config']['tenancy.filesystem.suffix_base'] . tenant('uuid');
// storage_path()
$this->app->useStoragePath($old['storage_path'] . "/{$suffix}");
// Storage facade
foreach ($this->app['config']['tenancy.filesystem.disks'] as $disk) {
$root = $this->app['config']["filesystems.disks.{$disk}.root"];
\Storage::disk($disk)->getAdapter()->setPathPrefix(
$root . "/{$suffix}"
);
if ($root = str_replace('%storage_path%', storage_path(), $this->app['config']["tenancy.filesystem.root_override.{$disk}"])) {
Storage::disk($disk)->getAdapter()->setPathPrefix($root);
} else {
$root = $this->app['config']["filesystems.disks.{$disk}.root"];
Storage::disk($disk)->getAdapter()->setPathPrefix($root . "/{$suffix}");
}
$old['storage_disks'][$disk] = $root;
}
// storage_path()
$this->app->useStoragePath($old['storage_path'] . "/{$suffix}");
$this->oldStoragePaths = $old;
}
}

View file

@ -26,8 +26,14 @@ return [
// Disks which should be suffixed with the suffix_base + tenant UUID.
'disks' => [
'local',
'public',
// 's3',
],
'root_override' => [
// Disks whose roots should be overriden after storage_path() is suffixed.
'local' => '%storage_path%/app/',
'public' => '%storage_path%/app/public/',
],
],
'database_managers' => [
'sqlite' => 'Stancl\Tenancy\TenantDatabaseManagers\SQLiteDatabaseManager',

View file

@ -1,5 +1,5 @@
<?php
Route::get('/tenancy/assets/{path}', 'Stancl\Tenancy\Controllers\TenantAssetController@asset')
Route::get('/tenancy/assets/{path}', 'Stancl\Tenancy\Controllers\TenantAssetsController@asset')
->where('path', '(.*)')
->name('stancl.tenancy.asset');