Skip to content
Advertisement

Deleting multiple records in laravel using foreach loop

I am trying to delete multiple images using product_id, I am able to delete one image at a time but am figuring out how i can insert a variable like $i=0 to a loop over but it does not work in laravel. so far this is my code

JavaScript

Advertisement

Answer

The findOrFail method return only one item. So you cannot iterate over it.

You can use the each method

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement