get()->modelKeys(); } static function checkForUserExists($login='',$password=''){ $validator = Validator::make( [ 'login' => $login, 'password' => $password, ], [ 'login' => 'required|max:255', 'password' => 'required|max:255', ], [ 'required' => ':attribute est obligatoire.', 'max' => 'La longueur de :attribute est de :size maximum.', ] ); if($validator->fails()) throw new Exception($validator->errors()); if(!UserModel::where([ 'login'=>$login, 'password'=>$password, ])->exists()) return false; return UserModel::select('id', 'isadmin') ->where('login', $login) ->where('password', $password) ->first()->toArray(); } static function getUserList($level=''){ if(empty($level) && $level!=='0') throw new Exception('Niveau obligatoire'); $users=[]; $usersCollection=UserModel::where('isadmin',$level)->get(); foreach($usersCollection as $user){ $users[]=[ 'id'=> $user->id, 'login' => $user->login, 'email' => $user->email, 'password' => $user->password, 'token' => $user->token, 'isadmin' => $user->isadmin, 'creation_date' => $user->creation_date, 'modification_date' => $user->modification_date, ]; } return $users; } }