mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 21:54:03 +00:00
make Create/DeleteTenantStorage listeners handle existing/missing directories gracefully
This commit is contained in:
parent
ac8a30d782
commit
aa6bfb4079
2 changed files with 10 additions and 3 deletions
|
|
@ -11,8 +11,11 @@ class CreateTenantStorage
|
||||||
public function handle(TenantCreated $event): void
|
public function handle(TenantCreated $event): void
|
||||||
{
|
{
|
||||||
$storage_path = tenancy()->run($event->tenant, fn () => storage_path());
|
$storage_path = tenancy()->run($event->tenant, fn () => storage_path());
|
||||||
|
$cache_path = "$storage_path/framework/cache";
|
||||||
|
|
||||||
mkdir("$storage_path", 0777, true); // Create the tenant's folder inside storage/
|
if (! is_dir($cache_path)) {
|
||||||
mkdir("$storage_path/framework/cache", 0777, true); // Create /framework/cache inside the tenant's storage (used for e.g. real-time facades)
|
// Create the tenant's storage directory and /framework/cache within (used for e.g. real-time facades)
|
||||||
|
mkdir($cache_path, 0777, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,10 @@ class DeleteTenantStorage
|
||||||
{
|
{
|
||||||
public function handle(DeletingTenant $event): void
|
public function handle(DeletingTenant $event): void
|
||||||
{
|
{
|
||||||
File::deleteDirectory(tenancy()->run($event->tenant, fn () => storage_path()));
|
$path = tenancy()->run($event->tenant, fn () => storage_path());
|
||||||
|
|
||||||
|
if (is_dir($path)) {
|
||||||
|
File::deleteDirectory($path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue