/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $photoGallery = PhotoGallery::findOrFail($id); if (!((\Auth::user() ? \Auth::user()->id : 0) == $photoGallery->created_by)) { abort('403', 'You are not allowed to delete the photoAlbum.'); } foreach ($photoGallery->photos as $photo) { unlink($photo->file_path); } $photoGallery->photos()->delete(); $photoGallery->delete(); return \Redirect::back(); }