37 lines
1014 B
PHP
37 lines
1014 B
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\TenantResource\Pages;
|
|
|
|
use App\Filament\Resources\TenantResource;
|
|
use App\Models\User;
|
|
use Filament\Actions;
|
|
use Filament\Resources\Pages\ListRecords;
|
|
|
|
class ListTenants extends ListRecords
|
|
{
|
|
protected static string $resource = TenantResource::class;
|
|
|
|
public function mount(): void
|
|
{
|
|
parent::mount();
|
|
|
|
$user = auth()->user();
|
|
|
|
if ($user instanceof User && ! $user->tenantMemberships()->exists()) {
|
|
abort(404);
|
|
}
|
|
}
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Actions\Action::make('add_managed_tenant')
|
|
->label('Add managed tenant')
|
|
->icon('heroicon-o-plus')
|
|
->url('/admin/managed-tenants/onboarding')
|
|
->disabled(fn (): bool => ! TenantResource::canCreate())
|
|
->tooltip(fn (): ?string => TenantResource::canCreate() ? null : 'You do not have permission to register tenants.'),
|
|
];
|
|
}
|
|
}
|