<?php

namespace App\Filament\Resources\FacilitymemberResource\Pages;

use App\Filament\Resources\FacilitymemberResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use Filament\Notifications\Notification;
use Illuminate\Support\Facades\Gate;
class EditFacilitymember extends EditRecord
{
    protected static string $resource = FacilitymemberResource::class;

    protected function getHeaderActions(): array
    {
        return [
            Actions\DeleteAction::make()
                ->before(function () {
                    // Add any pre-delete logic here
                })
                ->visible(fn () => Gate::allows('delete facilitymember')),
            Actions\ForceDeleteAction::make()
                ->visible(fn () => Gate::allows('force delete facilitymember')),
            Actions\RestoreAction::make()
                ->visible(fn () => Gate::allows('restore facilitymember')),
        ];
    }

    protected function getRedirectUrl(): string
    {
        return $this->getResource()::getUrl('index');
    }

    protected function getSavedNotification(): ?Notification
    {
        return Notification::make()
            ->success()
            ->title('Member updated')
            ->body('The facility member has been updated successfully.');
    }

    protected function mutateFormDataBeforeSave(array $data): array
    {
        // Add any data transformation logic here
        return $data;
    }
}