<?php

namespace App\Filament\Resources\BackupScheduleResource\Pages;

use App\Filament\Resources\BackupScheduleResource;
use Filament\Resources\Pages\EditRecord;
use Illuminate\Database\Eloquent\Model;

class EditBackupSchedule extends EditRecord
{
    protected static string $resource = BackupScheduleResource::class;

    protected function resolveRecord(int|string $key): Model
    {
        return BackupScheduleResource::resolveScopedRecordOrFail($key);
    }

    protected function mutateFormDataBeforeSave(array $data): array
    {
        $data = BackupScheduleResource::ensurePolicyTypes($data);

        return BackupScheduleResource::hydrateNextRun($data);
    }
}
