Проверка поля на изображение в Laravel 5
Стоит правило на проверка что файл должен быть изображение
class CommentStoreRequest extends FormRequest
{
public function rules()
{
return [
'bot' => 'accepted',
'message' => 'accepted',
'product_id' => 'integer|nullable',
'rate' => 'integer',
'name' => ['required','string','min:2','max:255','regex:/[А-Яа-яЁё]/u'],
'city' => 'string|min:3|max:125',
'description' => 'string|min:2|max:2048',
'user_id' => 'integer|exists:users,id|nullable',
'created_at' => 'date|date_format:Y-m-d H:i:s|nullable',
'file_1' => 'image',
'file_2' => 'image',
'file_3' => 'image',
];
}
}
class CommentController extends BaseController
{
final public function storeProduct(
CommentStoreRequest $request,
ProductRepository $productRepository
)
{
$comment = Comment::create($request->all());
if( $request->file('file_1')) {
$comment->addMediaFromRequest('file_1')->toMediaCollection('comment');
}
if( $request->file('file_2')) {
$comment->addMediaFromRequest('file_2')->toMediaCollection('comment');
}
if( $request->file('file_3')) {
$comment->addMediaFromRequest('file_3')->toMediaCollection('comment');
}
$product->comments()->save($comment);
}
}
Но при обработке формы возвращается ошибка
message: "The given data was invalid.",…}
errors: {file_1: ["Поле file 1 должно быть изображением."], file_2: ["Поле file 2 должно быть изображением."]}
file_1: ["Поле file 1 должно быть изображением."]
0: "Поле file 1 должно быть изображением."
file_2: ["Поле file 2 должно быть изображением."]
0: "Поле file 2 должно быть изображением."
message: "The given data was invalid."
Загружаю jpeg картинки Что может быть не так ?