Controller function:
public function addImages(Request $request,$imagesProductId)
{
$product = Product::create($request->all());
$filenames = array();
if ($request->images == '') {
return Redirect::back()->withErrors(['msg', 'The Message']);
}
if () {
// also need to validate on the extension and resolution of images
// (ie., if the validation fails the enum value will be "QCFailed")
} else {
foreach ($request->images as $photo) {
$filename = substr($photo->store('public/uploadedImages'), 22);
$filenames[] = asset('storage/uploadedImages/'.$filename);
ProductsPhoto::create([
'product_id' => $product->id,
'productId' => $imagesProductId,
'nonliveStatus' =>"QCVerified",
'filename' => $filename
]);
}
// echo('nonliveStatus');
}
return response()->json($filenames);
}
This is myfunction to insert array of images.For that I have used two model.The array of images get inserted but based on the validation the enum value should inserted respectively..My validations are the images are required and max size and its extensions