<?php

namespace App\Filament\Resources\AlbumResource\Pages;

use App\Filament\Resources\AlbumResource;
use App\Models\Album;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
use Illuminate\Database\Eloquent\Model;

class CreateAlbum extends CreateRecord
{
    protected static string $resource = AlbumResource::class;
    protected static bool $canCreateAnother = false;

    protected function getRedirectUrl(): string
    {
        return $this->getResource()::getUrl('index');
    }
    protected function handleRecordCreation(array $data): Model
    {
        $data['link'] = "";
        if($data["upload_type"] == 1){
            $data['link'] = $data["link_video"];
        }elseif($data["upload_type"] == 2){
            $data['link'] = $data["link_upload"];
        }

        return static::getModel()::create($data);
    }
}
