How to make the test array of the images in laravel?

Hello prompt how to write a rule for checking array images.
<input type="file" name="image[]" id="image" >
 <input type="file" name="image[]" id="image" >
 <input type="file" name="image[]" id="image" >
 <input type="file" name="image[]" id="image" >


The controller method store
public function store(Request $request){
$this->validate($request,[
"image" => And here I do not know how to prescribe the test of each element of the array.
]);
}
March 19th 20 at 09:09
2 answers
March 19th 20 at 09:11
Solution
image.*:
[
 'image' => ['array'],
 'image.*' => ['image']
]
Thanks for the reply. - Tiara.Reichert51 commented on March 19th 20 at 09:14
@Tiara.Reichert51, no problem) - zetta25 commented on March 19th 20 at 09:17
March 19th 20 at 09:13
Solution
Yes thank you, the validation works. I can still tell.
$this->validate($request, [
 "image" => "required|array|min:2",
 "image.*" => "mimes:jpg"
 ]);

Why if the error from the first image by scanning the array shows errors
@if($errors->has('image'))
{{$errors->first('image')}}
@endif
And if the error in the array element "image.*" => "mimes:png"
The errors do not seem to redirect just comes back and the error text is not visible.
How can they withdraw? - Tiara.Reichert51 commented on March 19th 20 at 09:16
@Tiara.Reichert51, well, you dunnite array of errors somewhere.

There must be some mistake, simply attached to a field can not due to the fact that it's an array, not a field one. - Neal commented on March 19th 20 at 09:19
Yes, exactly, the error seemed dd($errors->all())
Then it turned out so bring
@if($errors->has("image.*"))
{{$errors->first()}}
@endif
Thanks for the help. - Tiara.Reichert51 commented on March 19th 20 at 09:22

Find more questions by tags Laravel