Ejemplo n.º 1
0
 /**
  * @api {get} /users/get Get all users
  * @apiName Get all Active Users
  * @apiGroup User
  * @apiHeader (Header) {String} X_Authorization Authorization value.
  * @apiParam  (url Parameter) {Number} idUser Users unique ID.
  *
  * @apiError 400 Input Invalid. This will happen if the param is missing or not the valid format.
  * @apiError 404 Not found. This will happen if the role id/user id/group id is not in our system.
  * @apiError 401 Not authorized. This will happen if the header value is not attached.
  *
  * @apiSuccessExample {json} Success-Response:
  *   HTTP/1.1 200 OK
  *   [
  *   {
  *    "id": 2,
  *    "last_name": <last name>,
  *    "first_name": <first_name>,
  *    "email": <email>,
  *    "last_login": "******",
  *    "account_creation": "2015-11-11 00:00:00"
  *   }
  *   ]
  *
  */
 public static function getAllUsers()
 {
     $users = User::where('active', 1)->get();
     $tmpUsers = User::where('email', "")->get();
     // per requirements - filtering out superadmins
     foreach ($users as $key => $user) {
         if (AuthController::isSuperadmin($user->id)) {
             //	unset($users[$key]);
         } else {
             unset($user->phone);
             unset($user->theme);
             unset($user->active);
             unset($user->address);
             unset($user->city);
             unset($user->province);
             unset($user->country);
             unset($user->zip_code);
             unset($user->updated_at);
             unset($user->password);
             unset($user->avatar);
             unset($user->username);
             $tmpUsers->add($user);
         }
     }
     return $tmpUsers->toJson();
 }