Example #1
0
 /**
  * Show user related resources.
  *
  * @return \Illuminate\Http\Response
  */
 public function getResource($id = 0, $filename)
 {
     if ($id == 0) {
         $id = Auth::user()->id;
     }
     if (DB::table('users')->where('id', $id)->first() == null) {
         return abort(401);
     }
     $file = 'users/' . $id . '/' . $filename;
     if (!Storage::has($file)) {
         return abort(404);
     }
     $mimeType = Storage::mimeType($file);
     if (!Helper::startsWith($mimeType, 'image/')) {
         return abort(404);
     }
     $file = Storage::get($file);
     $response = Response::make($file, 200);
     $response->header("Content-Type", $mimeType);
     return $response;
 }