What I am trying to achieve is to delete multiple photos from one delete command, but it only delete the record from the database, but unable to delete the file in my local storage. I am trying to use unlink() method in order to make this to work. I hope somebody would enlighten me where that I made my mistake. Thank you!
Delete method
//There are 8 columns of image, the database record is wiped, but not in the local storage.
public function destroy(Gallery $gallery){
for ($i = 1; $i < 9; $i++) {
$path = storage_path('app/public/' . $gallery->image_ . $i);
if (file_exists($path)) {
@unlink($path);
}
}
$gallery->delete();
}