<?php

namespace App\Http\Requests\Admin;

use Illuminate\Foundation\Http\FormRequest;

class StoreShowRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'showId' => ['required', 'string', 'max:50', 'unique:shows,showId'],
            'title' => ['required', 'string', 'max:255'],
            'description' => ['nullable', 'string'],
            'lineup' => ['nullable', 'array'],
            'seitansai' => ['nullable', 'array'],
            'graduation' => ['nullable', 'array'],
            'start_time' => ['required', 'integer'],
            'type' => ['required', 'string', 'max:50'],
            'price' => ['required', 'numeric', 'min:0', 'decimal:0,2'],
            'coin_price' => ['nullable', 'integer', 'min:0'],
            'banner_link' => ['nullable', 'string', 'max:255', 'url'],
            'is_promo' => ['boolean'],
            'promo_price' => ['nullable', 'required_if:is_promo,true', 'numeric', 'min:0', 'decimal:0,2'],
            'promo_coin_price' => ['nullable', 'integer', 'min:0'],
            'is_active' => ['boolean'],
            'is_live' => ['boolean'],
            'is_replay' => ['boolean'],
            'streamer_live' => ['required', 'string', 'max:200'],
            'slug_live' => ['required', 'string', 'max:200', 'unique:shows,slug_live'],
            'url_live' => ['nullable', 'string', 'max:255', 'url'],
            'url_replay' => ['nullable', 'string', 'max:255', 'url'],
            'type_live' => ['required', 'string', 'max:50'],
        ];
    }

    /**
     * Get custom messages for validator errors.
     *
     * @return array<string, string>
     */
    public function messages(): array
    {
        return [
            'showId.required' => 'Show ID wajib diisi.',
            'showId.unique' => 'Show ID sudah terdaftar.',
            'title.required' => 'Judul wajib diisi.',
            'start_time.required' => 'Waktu mulai wajib diisi.',
            'start_time.integer' => 'Waktu mulai harus berupa angka.',
            'type.required' => 'Tipe show wajib diisi.',
            'price.required' => 'Harga wajib diisi.',
            'price.numeric' => 'Harga harus berupa angka.',
            'price.min' => 'Harga tidak boleh negatif.',
            'coin_price.integer' => 'Harga koin harus berupa angka bulat.',
            'coin_price.min' => 'Harga koin tidak boleh negatif.',
            'banner_link.url' => 'Link banner harus berupa URL yang valid.',
            'promo_price.required_if' => 'Harga promo wajib diisi jika show adalah promo.',
            'promo_price.numeric' => 'Harga promo harus berupa angka.',
            'promo_price.min' => 'Harga promo tidak boleh negatif.',
            'promo_coin_price.integer' => 'Harga koin promo harus berupa angka bulat.',
            'promo_coin_price.min' => 'Harga koin promo tidak boleh negatif.',
            'streamer_live.required' => 'Streamer live wajib diisi.',
            'slug_live.required' => 'Slug live wajib diisi.',
            'slug_live.unique' => 'Slug live sudah terdaftar.',
            'url_live.url' => 'URL live harus berupa URL yang valid.',
            'url_replay.url' => 'URL replay harus berupa URL yang valid.',
            'type_live.required' => 'Tipe live wajib diisi.',
        ];
    }
}
