public function getThumbnail($filename) { $entry = Fileentry::where('filename', '=', $filename)->firstOrFail(); $fs = new FileStorageController(); $file = $fs->getImage($entry->thumbnail_path); return (new Response($file, 200))->header('Content-Type', $entry->mime); }
public function destroyPicture($picture_id, $brand_id) { $brand = Brand::findOrFail($brand_id); //then we get the picture $picture = Fileentry::findOrFail($picture_id); $fs = new FileStorageController(); $fs->deleteImage($picture->path); // first we detach the file from the brand; $brand->pictures()->detach($picture_id); // then we delete the record in the database $picture->delete(); return \Response::json(['error' => false, 'code' => 200, 'feedback' => 'Brand picture removed.'], 200); }
public function destroyPicture($picture_id, $article_id) { $article = Article::findOrFail($article_id); //then we get the picture $picture = Fileentry::findOrFail($picture_id); //deletes the relationship of the file that is being deleted. $article->pictures()->detach($picture_id); $fs = new FileStorageController(); $fs->deleteImage($picture->path); // then we delete the record in the database $picture->delete(); return \Response::json(['error' => false, 'code' => 200, 'feedback' => 'Brand picture removed.'], 200); }