/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function picture($id) { try { $user = User::findOrFail($id); if ($user) { $picture = $user->picture; if ($picture) { $filename = base_path() . $picture->filename; if (File::exists($filename)) { $file_content = File::get($filename); } else { $file_content = $this->dummy_picture(); } return (new Response($file_content, Response::HTTP_OK))->header('Content-Type', $picture->mime_type); } else { return (new Response($this->dummy_picture(), Response::HTTP_OK))->header('Content-Type', 'image/jpeg'); } } return new Response('', Response::HTTP_NOT_FOUND); } catch (Exception $e) { return new Response($e->getMessage(), Response::HTTP_NOT_FOUND); } }