<?php

namespace App\Http\Requests\Admin;

use Illuminate\Foundation\Http\FormRequest;

class StoreNewsRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()->can('news.manage');
    }

    public function rules(): array
    {
        return [
            'title' => ['required', 'string', 'max:150'],
            'body' => ['required', 'string', 'max:20000'],
            'image' => ['nullable', 'image', 'max:4096'],
            'url' => ['nullable', 'url', 'max:255'],
            'published_at' => ['nullable', 'date'],
        ];
    }
}
