49 lines
1.5 KiB
PHP
49 lines
1.5 KiB
PHP
<?php
|
||
|
||
namespace App\Http\Requests\Announcement;
|
||
|
||
use App\Enums\AnnouncementCategory;
|
||
use Illuminate\Foundation\Http\FormRequest;
|
||
use Illuminate\Validation\Rule;
|
||
|
||
class StoreAnnouncementRequest extends FormRequest
|
||
{
|
||
public function authorize(): bool
|
||
{
|
||
return true;
|
||
}
|
||
|
||
/**
|
||
* @return array<string, array<int, mixed>>
|
||
*/
|
||
public function rules(): array
|
||
{
|
||
return [
|
||
'slug' => ['required', 'string', 'max:255', 'unique:announcements,slug'],
|
||
'title' => ['required', 'string', 'max:255'],
|
||
'category' => ['required', 'string', Rule::enum(AnnouncementCategory::class)],
|
||
'excerpt' => ['nullable', 'string', 'max:500'],
|
||
'content' => ['required', 'string'],
|
||
'image' => ['nullable', 'string', 'max:255'],
|
||
'is_featured' => ['sometimes', 'boolean'],
|
||
'meta_title' => ['nullable', 'string', 'max:255'],
|
||
'meta_description' => ['nullable', 'string', 'max:255'],
|
||
'published_at' => ['nullable', 'date'],
|
||
];
|
||
}
|
||
|
||
/**
|
||
* @return array<string, string>
|
||
*/
|
||
public function messages(): array
|
||
{
|
||
return [
|
||
'slug.required' => 'URL slug alanı zorunludur.',
|
||
'slug.unique' => 'Bu slug zaten kullanılıyor.',
|
||
'title.required' => 'Başlık zorunludur.',
|
||
'category.required' => 'Kategori zorunludur.',
|
||
'content.required' => 'İçerik zorunludur.',
|
||
];
|
||
}
|
||
}
|