2024-02-01 12:49:25 +00:00

40 lines
971 B
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreArticleRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'title' => 'required|string|max:255|unique:articles',
'body' => 'required|not_in:<p><br></p>',
'excerpt' => 'required',
'image' => 'required|image|mimes:png,jpg,jpeg|max:2048',
];
}
public function messages()
{
return [
'image.max' => 'The image size must not be greater than 2MB.',
'body.not_in' => 'The body field is required.'
];
}
}