hello everybody im trying to delete an image from local storage with this function but it returns
Call to a member function delete() on string
which is right because when I use dd(destination);
this is the result:
public/imagen/1634302328.jpg
is there a way to convert that string into a route path or other solution to delete an image from storage? thanks
this is my function:
public function destroy($id)
{
$autoridad = Autoridad::find($id);
$destination = 'public/imagen/'.$autoridad->imagen;
if(File::exists($destination)){
File::delete($destination);
}
$destination->delete();
return redirect()->route('autoridades.index');
}
}