first commit
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Enums\PostStatus;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
|
||||
class StorePostRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'category_id' => ['nullable', 'exists:categories,id'],
|
||||
'title' => ['required', 'string', 'max:255'],
|
||||
'slug' => ['nullable', 'string', 'max:255', Rule::unique('posts', 'slug')],
|
||||
'excerpt' => ['nullable', 'string', 'max:255'],
|
||||
'body' => ['required', 'string'],
|
||||
'featured_image' => ['nullable', 'string'],
|
||||
'status' => ['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'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user