I've saved images of posts in different sub-folders inside public/images like featured_image (public/images/featured_image), banner(public/images/banner). I want to delete images(featured_image and banner) related to post when banner is deleted.
This is my setup in filesystem.php
'local' => [
'driver' => 'local',
'root' => public_path('images/'),
],
I'm trying this to delete posts and images related to this:
public function destroy($id)
{
//
$tour = Tour::find($id);
$tour->country()->detach();
Storage::delete('featured_image/$tour->featured_image');
Storage::delete('banner/$tour->banner');
$tour->delete();
Session::flash('success', 'The tour is sucessfully deleted.');
return redirect()->route('tours.index');
}
The post gets deleted successfully but the images are not deleted from the folder. Please suggest the possible solution.