<?php

namespace App\Filament\Resources\AiModels\Pages;

use App\Filament\Resources\AiModels\AiModelResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
use Illuminate\Http\Request;

class CreateAiModel extends CreateRecord
{
    protected static string $resource = AiModelResource::class;

    public function mount(): void
    {
        parent::mount();

        if ($sourceRecordId = request()->query('sourceRecord')) {
            $sourceRecord = \App\Models\AiModel::find($sourceRecordId);
            if ($sourceRecord) {
                $this->form->fill($sourceRecord->attributesToArray());
            }
        }
    }

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