TenantAtlas/app/Filament/Resources/TenantResource/Pages/EditTenant.php
2026-01-30 17:51:24 +01:00

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();
}),
),
];
}
}