Files
omg-wtf-ai/app/Http/Requests/UpdatePostRequest.php
T

38 lines
1.2 KiB
PHP
Raw Normal View History

2026-08-08 18:03:29 +03:00
<?php
namespace App\Http\Requests;
use App\Enums\PostStatus;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\Enum;
class UpdatePostRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
/**
* @return array<string, mixed>
*/
public function rules(): array
{
return [
'category_id' => ['nullable', 'exists:categories,id'],
'title' => ['sometimes', 'required', 'string', 'max:255'],
'slug' => ['sometimes', 'required', 'string', 'max:255', Rule::unique('posts', 'slug')->ignore($this->route('post'))],
'excerpt' => ['nullable', 'string', 'max:255'],
'body' => ['sometimes', 'required', 'string'],
'featured_image' => ['nullable', 'string'],
'status' => ['sometimes', 'required', new Enum(PostStatus::class)],
'published_at' => ['nullable', 'date'],
'meta_title' => ['nullable', 'string', 'max:60'],
'meta_description' => ['nullable', 'string', 'max:160'],
'tags' => ['sometimes', 'array'],
'tags.*' => ['integer', 'exists:tags,id'],
];
}
}