Delete the file or image from storage in Laravel

if we use the Laravel storage system which one in the local public, when we store our files,

//in store function
public function store(){
  $file = $request->file('image);
  $fileName = 'product_'.time().'_'.$file->getClientOriginalName();
  $filePath = 'image/category/'. $fileName;
  Storage::disk('public')->put($filePath, file_get_contents($file));

Now, here is a note, Do not use storage in the file path name. example $filePath = 'storage/image/category/'. $fileName;

$filePath = 'storage/image/category/'. $fileName; //don't use that

$filePath = '/image/category/'. $fileName; //use that

Now if we want to delete our file,

//First fetch the file path from a model or whatever you want to fetch that data

If you want to show your images are going to be public you should probably move the folder into public.


Then you can print them with