<?php

namespace App\Http\Requests;

use App\Models\Feed;
use Illuminate\Foundation\Http\FormRequest;

class UpdateFeedRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    /**
     * @return array<string, string>
     */
    public function rules(): array
    {
        return [
            'name' => 'required|string|max:255',
            'url' => 'required|url|unique:feeds,url,'.($this->route('feed') instanceof Feed ? (string) $this->route('feed')->id : (string) $this->route('feed')),
            'type' => 'required|in:website,rss',
            'language_id' => 'required|exists:languages,id',
            'description' => 'nullable|string',
            'is_active' => 'boolean',
        ];
    }
}
