<?php

namespace App\Filament\Resources\OnlineResourcesResource\Pages;

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

    protected function getHeaderActions(): array
    {
        return [
            Actions\DeleteAction::make()
                ->visible(fn () => Gate::allows('delete onlineresource')),
        ];
    }

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

    protected function getSavedNotification(): ?Notification
    {
        return Notification::make()
            ->success()
            ->title('Online Resource updated successfully')
            ->body('The online resource has been updated successfully.');
    }

    protected function mutateFormDataBeforeSave(array $data): array
    {
        return $data;
    }
}