41 lines
1.3 KiB
PHP
41 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\TenantResource\Pages;
|
|
|
|
use App\Filament\Resources\TenantResource;
|
|
use App\Models\Tenant;
|
|
use App\Support\Auth\Capabilities;
|
|
use App\Support\Auth\UiEnforcement;
|
|
use Filament\Actions;
|
|
use Filament\Resources\Pages\EditRecord;
|
|
|
|
class EditTenant extends EditRecord
|
|
{
|
|
protected static string $resource = TenantResource::class;
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Actions\ViewAction::make(),
|
|
UiEnforcement::for(Capabilities::TENANT_DELETE)
|
|
->tenantFromRecord()
|
|
->apply(
|
|
Actions\Action::make('archive')
|
|
->label('Archive')
|
|
->color('danger')
|
|
->requiresConfirmation()
|
|
->visible(fn (): bool => $this->record instanceof Tenant && ! $this->record->trashed())
|
|
->action(function (): void {
|
|
$tenant = $this->record;
|
|
|
|
UiEnforcement::for(Capabilities::TENANT_DELETE)
|
|
->tenantFromRecord()
|
|
->authorizeOrAbort($tenant);
|
|
|
|
$tenant->delete();
|
|
}),
|
|
),
|
|
];
|
|
}
|
|
}
|