当前位置: 首页>>代码示例>>PHP>>正文


PHP User::where方法代码示例

本文整理汇总了PHP中RainLab\User\Models\User::where方法的典型用法代码示例。如果您正苦于以下问题:PHP User::where方法的具体用法?PHP User::where怎么用?PHP User::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RainLab\User\Models\User的用法示例。


在下文中一共展示了User::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postValidPincode

 public function postValidPincode()
 {
     if (!Auth::check()) {
         return Response::json(array('status' => 'error', 'message' => trans(CLF_LANG_MESSAGE . 'require_signin')), 500);
     }
     if (!Input::has('pincode')) {
         return;
     }
     $rules = array('pincode' => 'required|alpha_num|size:4');
     if ($response = self::valid($rules)) {
         return Response::json($response);
     }
     //$phone_number = Input::get('phone_number');
     $user_id = Auth::getUser()->id;
     $pincode = Input::get('pincode');
     // Get pincode inactive
     $check = Pincode::getLastPincodeInActive($user_id, $pincode);
     if ($check && !empty($check->phone_number)) {
         // Exists pincode inactive in db
         if (Pincode::ActivePincode($check->phone_number)) {
             // Update user has actived
             $user = User::where('id', $user_id)->update(array('is_validated' => 1, 'phone_number' => $check->phone_number));
             if (isset($user->errors)) {
                 return Response::json(response_message(400, $user->errors()->first()), 400);
             }
         }
         return Response::json(response_message(200));
     } else {
         return Response::json(response_message(1006));
     }
 }
开发者ID:httvncoder,项目名称:151722441,代码行数:31,代码来源:RestPincode.php

示例2: loadData

 protected function loadData()
 {
     $days = $this->property('days');
     if (!$days) {
         throw new ApplicationException('Invalid days value: ' . $days);
     }
     // all accesses for last month
     $items = User::where('created_at', '>=', Carbon::now()->subDays($days)->format('Y-m-d'))->get();
     // parse data
     $all = [];
     foreach ($items as $item) {
         // date
         $timestamp = strtotime($item->created_at) * 1000;
         $day = Carbon::createFromFormat('Y-m-d H:i:s', $item->created_at)->format('Y-m-d');
         if (isset($all[$day])) {
             $all[$day][1]++;
         } else {
             $all[$day] = [$timestamp, 1];
         }
     }
     // count all
     $all_render = [];
     foreach ($all as $a) {
         $all_render[] = [$a[0], $a[1]];
     }
     return $all_render;
 }
开发者ID:vojtasvoboda,项目名称:oc-useraccesslog-plugin,代码行数:27,代码来源:Registrations.php

示例3: fire

 /**
  * Execute the console command.
  * @throws Exception
  */
 public function fire()
 {
     $login = $this->argument('login');
     if ($this->rainlab) {
         $rainlab = (bool) $this->option('rainlab');
     } else {
         $rainlab = false;
     }
     if ($rainlab) {
         $user = \RainLab\User\Models\User::where('email', '=', $login)->orWhere('username', '=', $login)->first();
     } else {
         $user = User::whereLogin($login)->first();
     }
     if (!$user) {
         return $this->error('User not found');
     }
     $password = $this->option('password');
     if ($rainlab) {
         $login = 'RainLab.User => ' . $login;
     } else {
         $login = 'Backend.User => ' . $login;
     }
     if ($password == null) {
         $password = $this->ask('Set password for ' . $login . ' (or press Enter to skip)');
     }
     if ($password == null) {
         $password = Str::random(5);
     }
     $user->update(['password' => $password, 'password_confirmation' => $password]);
     $message = "\n  -> new password for " . $login . ": ";
     $this->comment($message . $password);
     return;
 }
开发者ID:grohman,项目名称:oc-idwidgets,代码行数:37,代码来源:UserPassword.php

示例4: onDeleteSource

 public function onDeleteSource()
 {
     $userFrom = user::where('email', post('sourceOldEmail'))->find(post('sourceId'));
     if (!$userFrom) {
         return null;
     }
     $surname = $userFrom->surname;
     $name = $userFrom->name;
     $userFrom->delete();
     return ['#layout-flash-messages' => '<p data-control="flash-message" class="flash-message success" data-interval="5">User ' . $name . ' ' . $surname . ' has been deleted from the system.</p>'];
 }
开发者ID:aydancoskun,项目名称:octobercms,代码行数:11,代码来源:Merge.php

示例5: onUpdateFromCrm

 /**
  * Update Events from CRM
  */
 public function onUpdateFromCrm()
 {
     $crmuserevents = CRMUserEvent::isNotUpdated()->with(['user', 'event'])->get();
     \CW::info(['userevents' => $crmuserevents]);
     if (count($crmuserevents) == 0) {
         Flash::info("No UserEvents to Create/Update");
         // echo "ERROR!";
         return;
     }
     $crmuserevents->each(function ($userevent) {
         if ($userevent->user && $userevent->event) {
             \CW::info([$userevent]);
             $cmsuser = User::where('email', $userevent->user->email)->first();
             $cmsevent = Event::where('crm_event_id', $userevent->event->id)->with('course')->first();
             $cmscourse = $cmsevent->course;
             $cmsusereventstate = UserEventState::where('crm_state_id', $userevent->state_id)->first();
             // $cmsuserevent = UserEvent::firstOrNew(['crm_event_id' => $userevent->event->id, 'user_id' => $cmsuser->id]);
             // $cmsuserevent = $cmsuser->userevents()
             // $cmsuserevent = $cmsuserevent
             $cmsuserevent = UserEvent::where('user_id', $cmsuser->id)->where('event_id', $cmsevent->id)->first();
             if (!$cmsuserevent) {
                 $cmsuserevent = new UserEvent();
             }
             \CW::info([$cmsuser, $cmsevent, $cmscourse, $cmsuserevent, $cmsusereventstate]);
             // if (!$cmsuser) {
             //     Log::warning("CMSUser is NULL\n");
             // }
             // if (!$cmsevent) {
             //     Log::warning("CMSEvent is NULL\n");
             // }
             // if (!$cmscourse) {
             //     Log::warning("CMSCourse is NULL\n");
             // }
             // if (!$cmsuserevent) {
             //     Log::warning("CMSUserEvent is NULL\n");
             // }
             // if (!$cmsusereventstate) {
             //     Log::warning("CMSUserEventState is NULL\n");
             // }
             $cmsuserevent->user()->associate($cmsuser);
             $cmsuserevent->course()->associate($cmscourse);
             $cmsuserevent->state()->associate($cmsusereventstate);
             $cmsuserevent->event()->associate($cmsevent);
             $cmsuserevent->fill(['course_type_id' => $cmscourse->course_type_id, 'course_category_id' => $cmscourse->course_category_id, 'crm_event_id' => $userevent->event->id]);
             \CW::info([$cmsuserevent]);
             $cmsuserevent->save();
             $userevent->update(['is_updated' => true]);
         }
     });
     Flash::success("UserEvents is update");
 }
开发者ID:abnmt,项目名称:oc-mrc-plugin,代码行数:54,代码来源:UserEvents.php

示例6: migrate

 /**
  * Migrate auth from Kohana to Laravel/OctoberCMS.
  *
  * @param  string  $login     Username or email
  * @param  string  $password
  * @return  bool  Migrated
  */
 public static function migrate($login, $password)
 {
     if (!$login || !$password) {
         return false;
     }
     if (!($user = User::where('username', $login)->orWhere('email', $login)->first())) {
         return false;
     }
     if (!$user->password && self::check($password, $user->password_kohana)) {
         $user->password = $user->password_confirmation = $password;
         $user->forceSave();
         return true;
     }
     return false;
 }
开发者ID:anqqa,项目名称:klubitus-octobercms-plugins,代码行数:22,代码来源:KohanaAuth.php

示例7: onPrintCard

 public function onPrintCard()
 {
     $locationId = post('printerLocation');
     if (empty($locationId)) {
         Flash::error(Lang::get('dma.friends::lang.user.memberCardLocation'));
         return;
     }
     $location = Location::find($locationId);
     $user = post('User');
     $user = User::where('email', '=', $user['email'])->first();
     try {
         $manager = new PrintManager($location, $user);
         $manager->printIdCard();
         Flash::info(Lang::get('dma.friends::lang.user.memberCard', ['title' => $location->title]));
     } catch (SystemException $e) {
         Flash::error($e->getMessage());
     }
 }
开发者ID:janusnic,项目名称:OctoberFriends,代码行数:18,代码来源:PrintMembershipCard.php

示例8: onNotificationsReady

 public function onNotificationsReady()
 {
     Postman::listen(['sms', 'regex' => '/.*/'], function (IncomingMessage $message) {
         // Find user using mobile phone
         $phoneUser = $message->getFrom();
         // Getting first user match. Assuming that phone is
         // unique in the database
         if ($user = User::where('phone', $phoneUser)->orWhere('phone', str_replace('+1', '', $phoneUser))->first()) {
             // Get code from message
             $params['code'] = $code = $message->getContent();
             // process Activity code first
             if (!($activity = ActivityCode::process($user, $params))) {
                 // Not found activity with that code.
                 // Trying if is a object assession number
                 $activity = LikeWorkOfArt::process($user, $params);
             }
             // Send SMS and kiosk notification
             $typeMessage = $activity ? 'successful' : 'error';
             $template = 'activity_code_' . $typeMessage;
             Postman::send($template, function (NotificationMessage $notification) use($user, $code, $activity) {
                 // Reply to same phone number
                 $notification->to($user, $user->name);
                 // Send code and activity just in case we want to use in the template
                 $notification->addData(['code' => $code, 'activity' => $activity, 'viaSMS' => true]);
                 // Determine the content of the message
                 $holder = $activity ? 'activityMessage' : 'activityError';
                 $message = Session::pull($holder);
                 if (is_array($message)) {
                     foreach ($message as $m) {
                         $notification->message($m);
                     }
                 } else {
                     $notification->message($message);
                 }
             }, ['sms', 'kiosk']);
             Log::debug('Incoming SMS', ['user' => $user, 'code' => $code, 'activity' => $activity]);
         } else {
             Postman::send('simple', function (NotificationMessage $notification) use($phoneUser) {
                 $user = new User();
                 $user->phone = $phoneUser;
                 // Reply to same phone number
                 $notification->to($user, $user->name);
                 $notification->message(Lang::get('dma.friends::lang.user.memberPhoneNotFound'));
             }, ['sms']);
         }
     });
 }
开发者ID:janusnic,项目名称:OctoberFriends,代码行数:47,代码来源:FriendsEventHandler.php

示例9: onAvailableUser

 /**
  * Verify if the given user mail is not already register
  */
 public function onAvailableUser()
 {
     $email = post('email');
     $data = ['available' => true];
     if (User::where('email', $email)->count() > 0) {
         $data['available'] = false;
     }
     return $data;
 }
开发者ID:janusnic,项目名称:OctoberFriends,代码行数:12,代码来源:UserLogin.php

示例10: onSendMail

 /**
  * Sending Mail
  * */
 public function onSendMail()
 {
     /**
      * Getting form results
      * */
     $group_id = post('group');
     $subject = post('subject');
     $msg = post('message');
     $test_email = post('testEmail');
     /**
      * Checking if there's no data
      * */
     if ($subject == "" || $msg == "") {
         return Flash::warning(Lang::get('lilessam.frontendmailsender::lang.error_nodata'));
     }
     /**
      * Striping tags for the plain version of mail
      * */
     $msgPlain = strip_tags(post('message'));
     /**
      * Setting vars array for mail template
      * */
     $vars = ['subject' => $subject, 'msg' => $msg, 'msgPlain' => $msgPlain];
     /**
      * Check if the administrator want to send only a test message
      * */
     if ($test_email != "") {
         //email and subject array
         $array = ['email' => $test_email, 'subject' => $subject];
         //Sending mail
         Mail::send(['text' => $msgPlain, 'html' => $msg, 'raw' => true], $vars, function ($message) use($array) {
             $message->subject($array['subject']);
             $message->to($array['email'], "Test Reciever");
         });
         /**
          * Success message
          * */
         return Flash::success(Lang::get('lilessam.frontendmailsender::lang.test.sent'));
     }
     /**
      * Getting users count in this group
      * */
     $users_count = DB::table('users_groups')->where('user_group_id', $group_id)->count();
     /**
      * Checking if there's users in the group
      * */
     if ($users_count != 0) {
         //Fetching users
         $users_ids = DB::table('users_groups')->where('user_group_id', $group_id)->get();
         /**
          * Looping to send mail to every user
          * */
         foreach ($users_ids as $user_id) {
             //The user
             $user = User::where('id', $user_id->user_id)->first();
             //User and subject array
             $array = ['user' => $user, 'subject' => $subject];
             //Sending mail
             Mail::send(['text' => $msgPlain, 'html' => $msg, 'raw' => true], $vars, function ($message) use($array) {
                 $message->subject($array['subject']);
                 $message->to($array['user']->email, $array['user']->name);
             });
         }
         /**
          * Success Message
          * */
         Flash::success(Lang::get('lilessam.frontendmailsender::lang.sent') . $users_count . Lang::get('lilessam.frontendmailsender::lang.users'));
     } else {
         /**
          * Warning message that there's no users in this group
          * */
         Flash::warning(Lang::get('lilessam.frontendmailsender::lang.nousers'));
     }
 }
开发者ID:lilessam,项目名称:frontendmailsender,代码行数:77,代码来源:Frontendmailsender.php

示例11: onLoginWithFacebook

 /**
  * Successful login with Facebook.
  */
 public function onLoginWithFacebook()
 {
     $newUser = false;
     try {
         $accessToken = GraphAPI::instance()->getUserAccessToken(true);
         $response = GraphAPI::instance()->get('/me', ['id', 'email', 'name'], $accessToken);
         $facebookUser = $response->getGraphUser();
     } catch (SystemException $e) {
         Flash::error('Facebook login failed.');
         return;
     }
     $externalUser = UserExternalModel::facebook([$facebookUser->getId()])->first();
     if (!$externalUser) {
         // No user found by Facebook user id
         $user = UserModel::where('email', '=', $facebookUser->getEmail())->first();
         if (!$user) {
             // No user found by email either, sign up
             $newUser = true;
             $password = uniqid();
             $signup = ['username' => $facebookUser->getName(), 'name' => $facebookUser->getName(), 'email' => $facebookUser->getEmail(), 'password' => $password, 'password_confirmation' => $password];
             try {
                 $user = Auth::register($signup, true);
             } catch (ModelException $e) {
                 Log::error('Facebook sign up failed: ' . $e->getMessage());
                 $signup['username'] .= rand(1000, 9999);
                 try {
                     $user = Auth::register($signup, true);
                 } catch (ModelException $e) {
                     Log::error('Facebook sign up failed: ' . $e->getMessage());
                     Flash::error(Lang::get('klubitus.facebook::lang.register.register_failed'));
                     return;
                 }
             }
         }
         UserExternalModel::create(['user_id' => $user->id, 'provider' => UserExternalModel::PROVIDER_FACEBOOK, 'external_user_id' => $facebookUser->getId(), 'token' => $accessToken->getValue(), 'expires_at' => $accessToken->getExpiresAt()]);
     } else {
         $user = $externalUser->user;
     }
     Auth::login($user, true);
     if (post('redirect', true)) {
         if ($newUser) {
             return Redirect::to(post('redirect_signup', URL::previous() ?: Request::fullUrl()));
         } else {
             return Redirect::to(post('redirect_login', URL::previous() ?: Request::fullUrl()));
         }
     }
 }
开发者ID:anqqa,项目名称:klubitus-octobercms-plugins,代码行数:50,代码来源:FacebookConnect.php

示例12: onSearchUser

 /**
  * Ajax handler for searching users
  */
 public function onSearchUser()
 {
     // Suggest exsiting members
     if (($search = post('newUser')) != '') {
         $users = User::where($this->getLoginAttr(), 'LIKE', "{$search}%")->orWhere('name', 'LIKE', "{$search}%")->take($this->property('maxUserSuggestions'))->get();
         /*
         $users = User::groups()
                 ->wherePivot('membership_status', '<>', UserGroup::MEMBERSHIP_ACCEPTED )
                 ->with('groups')
                 ->whereHas('groups', function($query){
                     $query->where('is_active', true);
                 })
                
                 ->get();
         */
         // Updated list of users and other vars
         $this->prepareVars(null, ['search' => $search, 'users' => $users]);
     }
 }
开发者ID:janusnic,项目名称:OctoberFriends,代码行数:22,代码来源:GroupFormCreation.php

示例13: onAddMember

 /**
  * Ajax handler for adding members
  */
 public function onAddMember()
 {
     // refresh current step
     $this->currentStep = self::STEP_MEMBERS;
     if (($groupId = post('groupId')) != '') {
         // Add to group
         $group = $this->getGroup($groupId);
         if (($username = post('username')) != '') {
             $user = User::where($this->getLoginAttr(), '=', $username)->first();
             if ($user) {
                 \Log::info(UserGroup::getActiveMembershipsCount($user));
                 try {
                     $added = $group->addUser($user);
                     if (!$added) {
                         if ($user->getKey() == $group->owner->getKey()) {
                             $message = Lang::get('dma.friends::lang.groups.ownerCanBeMember');
                             Flash::error($message);
                         }
                     }
                 } catch (\Exception $e) {
                     Flash::error($e->getMessage());
                 }
             } else {
                 $message = Lang::get('dma.friends::lang.exceptions.userNotFound');
                 Flash::error($message);
             }
         }
         // Updated list of users and other vars
         $this->prepareVars($group);
     }
 }
开发者ID:janusnic,项目名称:OctoberFriends,代码行数:34,代码来源:GroupManager.php

示例14: isBarcode

 /**
  * Lookup user by barcode id
  *
  * @param string $id
  * An id to lookup by barcode id
  *
  * @return User $user
  * A RainLab\User\Model\User object
  */
 private static function isBarcode($id)
 {
     $user = User::where('barcode_id', $id)->first();
     if ($user) {
         return $user;
     }
     return false;
 }
开发者ID:janusnic,项目名称:OctoberFriends,代码行数:17,代码来源:AuthManager.php

示例15: getAllUsers

 /**
  * Get all users
  *
  * @return mixed
  */
 public function getAllUsers()
 {
     return User::where('is_activated', true)->get();
 }
开发者ID:vojtasvoboda,项目名称:oc-codelogin-plugin,代码行数:9,代码来源:UserRepository.php


注:本文中的RainLab\User\Models\User::where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。