public function update(Post $post){
$this->validateRequest();
$data = [
'title' => request()->title,
'content' => request()->content
];
if (request()->hasFile('image') && request('image') != '') {
$imagePath = public_path('storage/'.$post->image);
if(File::exists($imagePath)){
unlink($imagePath);
}
$image = request()->file('image')->store('uploads', 'public');
$data['image'] = $image;
$post->update($data);
}
$post->update($data);
}
//On top
use IlluminateSupportFacadesStorage;
//then
if(Storage::exists('your/path'.$file_name)){
Storage::delete('your/path'.$file_name);
/*
Delete Multiple File like this way
Storage::delete(['path/example.png', 'path/example2.png']);
*/
return true;
}