Ibe
3 months ago

How to delete multiple rows in storage?

Posted 3 months ago by Ibe

Hello there, I am having a little problem with deleting multiple items in de destroy function. Hope someone here can help... So basically the code works perfectly and when I delete a row it also deletes the picture in my public folder. The problem is that I now have two images (flags and shapes) and now it only works for one image..

So 1 image gets deleted in the storage, but the other image just stays in the folder... How can I get them both to delete?

Controller:

public function destroy($id)
    {
      $country = Country::find($id);

      Storage::delete($country->flag);
      Storage::delete($country->shape);

      $country->delete();
      return redirect()->route('countries.index');
    }

Thanks!

Please sign in or create an account to participate in this conversation.