<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

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

    /**
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        $songId = $this->route('song');

        return [
            'title' => ['required', 'string', 'max:255'],
            'ccli_id' => [
                'nullable',
                'string',
                'max:50',
                Rule::unique('songs', 'ccli_id')->ignore($songId)->whereNull('deleted_at'),
            ],
            'author' => ['nullable', 'string', 'max:255'],
            'copyright_text' => ['nullable', 'string', 'max:1000'],
            'copyright_year' => ['nullable', 'string', 'max:10'],
            'publisher' => ['nullable', 'string', 'max:255'],
            'has_translation' => ['nullable', 'boolean'],
        ];
    }
}
