/** * @param Store $store * @return \Symfony\Component\HttpFoundation\BinaryFileResponse */ public function getImage(Store $store) { if ($store->toArray() == []) { \App::abort(404, 'The API doesn\'t exist'); } $imageUrl = ""; $imageIndex = $store->img_url; if ($imageIndex != NULL) { $filePath = storage_path() . "/store_images/" . $imageIndex; return \Response::download($filePath, $store->title . ".jpg", ['Content-Type' => 'text/jpeg']); } \App::abort(404, 'The user doesn\'t have a valid image'); return []; }