/** * Get all user * @return mixed */ public function getAllUser() { $users = User::select('id', 'name', 'email')->get(); $users = $users->reject(function ($user) { return $user->hasRole('admin') === true; }); return $users; }
/** * Display a listing of the resource. * * @return Response */ public function index(DatabaseManager $db, Request $request) { $users = User::select('u_id', 'u_name', 'e-mail', 'location', 'skype', 'int_phone', 'desks.id as desk', 'departmants.job', 'departmants.dep', 'departmants.users as dep_users', 'rights.users as rights')->leftJoin('desks', 'users_id', '=', 'u_id')->leftJoin('rights', 'user_id', '=', 'u_id')->join('departmants', 'departmants.id', '=', 'departmant_id')->where('departmant_id', '!=', 21)->get()->keyBy('u_id')->toArray(); $host = getenv('COMPUTERNAME'); if (!in_array($host, ['SOFWKS0188', 'SOFWKS0159', 'SOFWKS0140'])) { $host = explode('.', gethostbyaddr($request->server->get('REMOTE_ADDR'))); $host = $host[0]; } $res = $db->table('computers')->select('user_id')->where('name', '=', $host)->first(); if ($res) { $users[$res->user_id]['current'] = true; $users[$res->user_id]['edit'] = $this->checkUser($users[$res->user_id]); } // Apply data restrictions if (empty($res) || !$users[$res->user_id]['edit']) { $users = $this->filterRestrictedData($users); } $users = array_merge($users, $this->getSpecialUsers()); return response()->json($users); }
public function getPowerById($id) { return User::select('power')->where('id', $id)->take(1)->get()[0]['power']; }
public function BB() { return \Bin\View\View::make('index.php')->with('a', User::select('select * from test', 'data')); }
/** * Check that a users email is unique. * * @param int $user_id The users id. * @param string $email The email address. * * @return int `0` for not in use, `1` for in use */ public function checkUniqueEmail($user_id, $email) { return $this->User->select('id')->where('email=? AND id<>?', array($email, $user_id))->limit(1)->data()->rowCount(); }