Exemplo n.º 1
0
 public function searchUsers($id)
 {
     $user = User::find($id);
     if (!$user) {
         return $this->respond([]);
     }
     return $this->respond($this->collectionTransformer->transformOtherUser($user));
 }
Exemplo n.º 2
0
 /**
  * Display the specified resource.
  * GET /users/{id}
  *
  * @param int $id
  * @return Response
  */
 public function show($id)
 {
     $user = Auth::user();
     //FIXME Ineffiecent code, double query
     $otherUser = User::withTrashed()->find($id);
     if (!$otherUser) {
         return $this->respondNotFound('user.not-found');
     }
     if ($otherUser->deleted_at) {
         return Response::json(['response' => ['id' => $otherUser->id, 'name' => $otherUser->name, 'status' => 'deleted', 'img' => ['thumb' => $otherUser->img_small, 'middle' => $otherUser->img_middle, 'origin' => $otherUser->img_origin]]]);
     }
     if ($user->isBlocked($id)) {
         return Response::json(['response' => ['id' => $otherUser->id, 'name' => $otherUser->name, 'status' => 'blocked', 'reason' => 'User blocked you', 'img' => ['thumb' => $otherUser->img_smal, 'middle' => $otherUser->img_middle, 'origin' => $otherUser->img_origin], 'in_blacklist' => $user->inBlackList($otherUser->id) ? 1 : 0]], 403);
     }
     if (!$otherUser) {
         return $this->respondNotFound('user.not-found');
     }
     $otherUser->load('cars', 'phones');
     return $this->respond($this->collectionTransformer->transformOtherUser($otherUser, Request::header('Locale')));
 }