本文整理汇总了PHP中app\models\Users::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::where方法的具体用法?PHP Users::where怎么用?PHP Users::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Users
的用法示例。
在下文中一共展示了Users::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loginPost
public function loginPost(Request $request)
{
$redirectTarget = $request->has('target') ? $request->get('target') : 'root-index';
$email = trim($request->get('email', ''));
$password = trim($request->get('password', ''));
$isRemember = $request->has('remember');
$user = Users::where('email', $email)->first();
if (empty($user)) {
Notifications::add('User not registered', 'danger', 'login');
return Redirect::route('login', ['target' => $redirectTarget])->withInput();
}
if (!Hash::check($password, $user->password)) {
Notifications::add('Wrong password', 'danger', 'login');
return Redirect::route('login', ['target' => $redirectTarget])->withInput();
}
if ($user->active != '1') {
Notifications::add('User is not allowed to log in', 'danger', 'login');
return Redirect::route('login', ['target' => $redirectTarget])->withInput();
}
try {
Auth::login($user, $isRemember);
} catch (QueryException $e) {
//just for demo purposes
}
return Redirect::route($redirectTarget);
}
示例2: index
public function index()
{
view()->share('menu_item_active', 'index');
Title::prepend('Dashboard');
$data = ['title' => Title::renderr(' : ', true), 'posts_total' => Posts::count(), 'posts_active' => Posts::where('status', 'active')->count(), 'posts_draft' => Posts::where('status', 'draft')->count(), 'posts_moderation' => Posts::where('status', 'moderation')->count(), 'users_total' => Users::count(), 'users_active' => Users::where('active', '1')->count(), 'users_inactive' => Users::where('active', '0')->count(), 'latest_posts' => Posts::active()->orderBy('published_at', 'desc')->limit(5)->get(), 'popular_posts' => Posts::active()->orderBy('views', 'desc')->limit(5)->get()];
return view('root.dashboard.index', $data);
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
if ($request->userID) {
$user = Users::where("uID", $request->userID)->first();
if ($request->password) {
$user->uPassword = md5($request->password);
}
} else {
$user = new Users();
$user->uPassword = md5($request->password);
$user->uRegisteredDate = date('Y-m-d');
$user->uIsActive = 1;
$user->uRole = 1;
$user->uUsername = $request->username;
$user->uEmail = $request->email;
}
$user->uBirthday = date('Y-m-d', strtotime($request->birthday));
$user->uAddress = $request->address;
$user->uPhone = $request->phone;
$file = Input::file('image');
// $file->getRealPath()
if (!is_null($file)) {
$destinationPath = public_path() . '/assets/images/avatar/';
$fileName = explode(".", $file->getClientOriginalName())[0];
$fileName = $fileName . rand(1, 9999) . "." . $file->getClientOriginalExtension();
Input::file('image')->move($destinationPath, $fileName);
Image::make($destinationPath . $fileName)->resize(400, 400)->save($destinationPath . '400x400/' . $fileName);
$user->uAvatar = $fileName;
}
$user->save();
return Redirect::action('admin\\user@index');
}
示例4: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$token = $request->get('token');
if ($token) {
$cacheTag = ['users'];
$cacheKey = $token;
$data = Cache::tags($cacheTag)->remember($cacheKey, 60 * 48, function () use($request, $token) {
$_user = Users::where('token', urldecode($token));
if ($_user->count() > 0) {
return $_user->first()->toArray();
} else {
return false;
}
});
if ($data) {
config(['global.users.current.id' => $data['id']]);
config(['global.users.current.token' => $token]);
config(['global.users.current.name' => $data['name']]);
config(['global.users.current.lastname' => $data['lastname']]);
config(['global.users.current.email' => $data['email']]);
config(['global.users.current.active' => $data['active']]);
} else {
Cache::tags($cacheTag)->forget($cacheKey);
}
}
return $next($request);
}
示例5: doLogin
public function doLogin($req, $res)
{
$allPostPutVars = $req->getParsedBody();
$auth_type = $this->containerSlim->get('systemOptions')->getValue('email_or_login') or 'email';
$errors = false;
if (!$allPostPutVars['password']) {
$errors = true;
$this->flash->addMessage('errors', 'The password attribute is required. ');
}
if (!$allPostPutVars[$auth_type]) {
$this->flash->addMessage('errors', 'The login attribute is required. ');
$errors = true;
}
$user = Users::where($auth_type, $allPostPutVars[$auth_type])->get();
if (!isset($user[0])) {
$this->flash->addMessage('errors', 'User no find in db.');
$errors = true;
} elseif (!$user[0]->active) {
$this->flash->addMessage('errors', 'User is no active. Please contact administrator system.');
$errors = true;
} elseif (!$user[0]->verifyPassword($allPostPutVars['password'])) {
$this->flash->addMessage('errors', 'User no find in system.');
$errors = true;
}
if ($errors) {
return $res->withStatus(302)->withHeader('Location', $this->router->pathFor('login'));
}
Session::put('auth', true);
Session::put('user', $user[0]->toArray());
return $res->withStatus(301)->withHeader('Location', '/admin/dashboard');
}
示例6: __construct
public function __construct()
{
$this->beforeFilter(function () {
$RequestedToken = $this->request->header("X-Authentication");
$Users = Users::where("BearerToken", "=", $RequestedToken)->first();
if (is_null($User)) {
return $this->response->errorUnauthorized();
}
});
}
示例7: store
/**
* Store a newly created resource in storage.
* POST
* @return Response
*/
public function store()
{
$Users = new Users();
$Users->first_name = 'Michael';
$Users->last_name = 'Pierre';
$Users->age = '31';
$Users->city = 'Orlando';
$Users->state = 'Florida';
$Users->country = 'USA';
$Users->about = 'Cool Dude';
$Users->save();
return Users::where('uid', $Users->id)->get();
}
示例8: checkImageCommentar
public static function checkImageCommentar($created_by)
{
$userCheck = \App\Models\Users::where(['created_by' => '$created_by']);
if ($userCheck->count() > 0) {
if (file_exists(public_path() . "/" . $userCheck->first()->image) && !empty($userCheck->first()->image)) {
return asset($userCheck->first()->image);
} else {
return asset("/images/default/no_image.jpg");
}
} else {
return asset("/images/default/no_image.jpg");
}
}
示例9: checkLogin
public function checkLogin()
{
$request = $this->request();
$session = $request->getSession();
$username = $request->get('username');
$password = $request->get('password');
if (empty($username) || empty($password)) {
return json_encode(array('status' => 0, 'msg' => '用户名或密码不能为空'), JSON_UNESCAPED_UNICODE);
}
$userinfo = Users::where('username', $username)->first();
//如果获取不到用户信息,返回提示信息
if (!$userinfo || $userinfo['password'] != md5($password)) {
return array('status' => 0, 'msg' => '用户名或者密码错误!');
}
$session->set('uid', $userinfo['id']);
return new RedirectResponse('/admin');
}
示例10: authen
public function authen($email, $password)
{
$validate = new Custom_Validator();
$arr_msg = $validate->isNull($email);
if (!$arr_msg["STATUS"]) {
$arr_msg["INPUT"] = "e-mail";
echo json_encode($arr_msg);
}
$arr_msg = $validate->isNull($password);
if (!$arr_msg["STATUS"]) {
$arr_msg["INPUT"] = "password";
echo json_encode($arr_msg);
}
$count = Users::where('user_email', '=', $email)->where('user_password', '=', $password)->where('user_flag', '=', UserFlag::$VERIFY[1])->count();
if ($count > 0) {
$user = Users::where('user_email', '=', $email)->where('user_password', '=', $password)->where('user_flag', '=', UserFlag::$VERIFY[1])->get();
$access_tokens = new Access_tokens();
$access_tokens->where('email', '=', $email)->delete();
$token = $this->generateToken($email);
$access_tokens->email = $email;
$access_tokens->token = $token;
$access_tokens->save();
$arr["email"] = $user[0]["user_email"];
$arr["name"] = $user[0]["user_name"];
$arr["lastname"] = $user[0]["user_lastname"];
$arr["access_token"] = $token;
$arr["authen"] = "Authentication success.";
$arr_msg["MESSAGE"] = "Authentication success.";
$arr_msg["MESSAGE_ARRAY"] = $arr;
$arr_msg["STATUS"] = true;
return json_encode($arr_msg);
} else {
$arr["authen"] = "Wrong username or password.";
$arr_msg["MESSAGE"] = "wrong e-mail or password.";
$arr_msg["MESSAGE_ARRAY"] = $arr;
$arr_msg["STATUS"] = false;
return json_encode($arr_msg);
}
}
示例11: loginPost
public function loginPost()
{
$redirectTarget = Input::has('target') ? Input::get('target') : 'root-index';
$email = trim(Input::get('email', ''));
$password = trim(Input::get('password', ''));
$isRemember = Input::has('remember');
$user = Users::where('email', $email)->first();
if (empty($user)) {
Notifications::add('User not registered', 'danger', 'login');
return Redirect::route('login', ['target' => $redirectTarget])->withInput();
}
if (!Hash::check($password, $user->password)) {
Notifications::add('Wrong password', 'danger', 'login');
return Redirect::route('login', ['target' => $redirectTarget])->withInput();
}
if ($user->active != '1') {
Notifications::add('User is not allowed to log in', 'danger', 'login');
return Redirect::route('login', ['target' => $redirectTarget])->withInput();
}
Auth::login($user, $isRemember);
return Redirect::route($redirectTarget);
}
示例12: search
public function search(Request $request)
{
\Log::info("in search");
$lastName = $request->input('last_name');
\Log::info("lastname={$lastName}");
$users = Users::where('last_name', 'like', $lastName . '%')->orWhere('first_name', $lastName)->get();
$result = "<option value=''>select User</option>";
foreach ($users as $user) {
$result .= "<option value='{$user->id}'>{$user->first_name} {$user->last_name}</option>";
}
$data = $this->userData($request);
$data['selectNames'] = $result;
$data['title'] = 'Admin';
$data['description'] = 'Admin';
return view('management', $data);
}
示例13: getDelete
public function getDelete($id)
{
Users::where('id', $id)->delete();
return redirect()->back();
}
示例14: checkForUserName
public function checkForUserName(Request $request)
{
return Users::where('user_name', $request->input('username'))->first();
}
示例15: getGeneration
public function getGeneration($user, $level)
{
\Log::info("id= {$user->id} level={$level}");
$field = $this->levelToField($level);
$users = Users::where($field, $user->id)->get();
return $users;
}