67 lines
2.3 KiB
PHP
67 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace Modules\Service\app\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class CreateServiceRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'title' => 'required|string|max:255',
|
|
'summary' => 'sometimes|nullable|string',
|
|
'detail' => 'sometimes|nullable|string',
|
|
'status' => 'required|in:active,inactive',
|
|
'meta_title' => 'sometimes|nullable|string|max:255',
|
|
'meta_description' => 'sometimes|nullable|string',
|
|
'meta_keywords' => 'sometimes|nullable|string|max:255',
|
|
'slug' => 'required',
|
|
// 'homepage_flag' => 'nullable|boolean',
|
|
'image' => 'sometimes|nullable|image|mimes:jpeg,png,jpg,gif',
|
|
];
|
|
}
|
|
|
|
|
|
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.',
|
|
|
|
'summary.string' => 'The summary field must be a string.',
|
|
|
|
'detail.string' => 'The detail field must be a string.',
|
|
|
|
'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.',
|
|
|
|
'slug.required' => 'The slug field is required.',
|
|
|
|
'image.image' => 'The image must be an image file.',
|
|
'image.mimes' => 'The image must be a file of type: jpeg, png, jpg, gif.',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
// return auth()->user()->can('users.create');
|
|
}
|
|
}
|