/** * delete content from the database * @param $id * @param $path * @return bool * @throws \Exception */ public static function deleteContent($id, $path) { $status = false; try { $galleryContent = GalleryContent::find($id); $path .= $galleryContent->contentName . '.' . $galleryContent->contentFileExtension; File::Delete($path); $galleryContent->delete(); $status = true; } catch (Exception $e) { } return $status; }
/** * @param $id * @return bool */ public function deleteImages($id) { $photos = Photo::whereFlyer_id($id)->get(); foreach ($photos as $image) { if (!File::Delete(public_path('images/home_pics/') . $image->path)) { return false; } } return true; }