Tenant Switch implemented Co-authored-by: Ahmed Darrazi <ahmeddarrazi@adsmac.local> Reviewed-on: #32
27 lines
603 B
PHP
27 lines
603 B
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\TenantResource\Pages;
|
|
|
|
use App\Filament\Resources\TenantResource;
|
|
use App\Models\User;
|
|
use App\Support\TenantRole;
|
|
use Filament\Resources\Pages\CreateRecord;
|
|
|
|
class CreateTenant extends CreateRecord
|
|
{
|
|
protected static string $resource = TenantResource::class;
|
|
|
|
protected function afterCreate(): void
|
|
{
|
|
$user = auth()->user();
|
|
|
|
if (! $user instanceof User) {
|
|
return;
|
|
}
|
|
|
|
$user->tenants()->syncWithoutDetaching([
|
|
$this->record->getKey() => ['role' => TenantRole::Owner->value],
|
|
]);
|
|
}
|
|
}
|