1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 19:34:04 +00:00

Let the user pass the tenant suffix by %tenant%

In this PR we let the user pass an additional parameter using `%tenant%` so the user can additionally pass the folder corresponding to each tenant.
This is my proposal, because if I try to use %storage_path% within Linux, I get the full path to the project when I use Google Cloud Storage
This commit is contained in:
Vincent GS 2022-03-04 02:01:51 -06:00 committed by GitHub
parent b4a4eab949
commit a2c8218e6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -58,12 +58,14 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper
/** @var FilesystemAdapter $filesystemDisk */
$filesystemDisk = Storage::disk($disk);
$this->originalPaths['disks'][$disk] = $filesystemDisk->getAdapter()->getPathPrefix();
$subject = $this->app['config']["tenancy.filesystem.root_override.{$disk}"] ?? '';
if ($root = str_replace(
'%storage_path%',
storage_path(),
$this->app['config']["tenancy.filesystem.root_override.{$disk}"] ?? ''
$subject
)) {
$root = str_replace('%tenant%', $suffix, $subject);
$filesystemDisk->getAdapter()->setPathPrefix($finalPrefix = $root);
} else {
$root = $this->app['config']["filesystems.disks.{$disk}.root"];