Files
aroginhealthcare/Modules/Blog/app/Http/Requests/CreateBlogRequest.php
2025-08-17 16:23:14 +05:45

77 lines
2.7 KiB
PHP

<?php
namespace Modules\Blog\app\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class CreateBlogRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*/
public function rules(): array
{
return [
'title' => 'required|string|max:255',
'content' => 'required|string',
'author' => 'required|string|max:255',
'summary' => 'required|string',
'published_date' => 'required|date',
'status' => 'required|in:active,inactive',
'meta_title' => 'sometimes|nullable|string|max:255',
'meta_description' => 'sometimes|nullable|string',
'meta_keywords' => 'sometimes|nullable|string|max:255',
'image' => 'sometimes|nullable|mimes:png,jpg,jpeg',
'slug' => 'required',
];
}
public function messages()
{
return [
'title.required' => 'The title field is required.',
'title.string' => 'The title field must be a string.',
'title.max' => 'The title may not be greater than 255 characters.',
'content.required' => 'The content field is required.',
'content.string' => 'The content field must be a string.',
'author.required' => 'The author field is required.',
'author.string' => 'The author field must be a string.',
'author.max' => 'The author may not be greater than 255 characters.',
'summary.required' => 'The summary field is required.',
'summary.string' => 'The summary field must be a string.',
'published_date.required' => 'The published date field is required.',
'published_date.date' => 'The published date field must be a valid date.',
'status.required' => 'The status field is required.',
'status.in' => 'The status field must be either "active" or "inactive".',
'meta_title.string' => 'The meta title field must be a string.',
'meta_title.max' => 'The meta title may not be greater than 255 characters.',
'meta_description.string' => 'The meta description field must be a string.',
'meta_keywords.string' => 'The meta keywords field must be a string.',
'meta_keywords.max' => 'The meta keywords may not be greater than 255 characters.',
'image.mimes' => 'The image must be a file of type: png, jpg, jpeg.',
'slug.required' => 'The slug field is required.',
];
}
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
// return auth()->user()->can('users.create');
}
}