<?php

namespace App\Http\Requests\Admin;

use App\Services\SupportBannerService;
use Illuminate\Foundation\Http\FormRequest;

/**
 * PRC-790 — destek duyuru banner'ı store/update validasyonu.
 * department_id null (Genel) veya geçerli bir ticket departmanı; end > start.
 */
class SupportBannerRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user('admin')?->can('manage support banners') ?? false;
    }

    public function rules(): array
    {
        return [
            'title' => ['required', 'string', 'max:150'],
            'message' => ['required', 'string', 'max:1000'],
            'style' => ['required', 'in:' . implode(',', SupportBannerService::STYLES)],
            'department_id' => ['nullable', 'integer', 'exists:ticket_departments,id'],
            'start_time' => ['required', 'date'],
            'end_time' => ['required', 'date', 'after:start_time'],
        ];
    }
}
