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


PHP User::find方法代码示例

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


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

示例1: decode

 /**
  * @inheritdoc
  */
 public function decode($jwt)
 {
     $payload = JWT::decode($jwt, $this->getSigningKey(), [self::SIGNING_ALGORITHM]);
     $userId = isset($payload->{self::CLAIM_USER_ID}) === true ? $payload->{self::CLAIM_USER_ID} : null;
     $user = $userId !== null ? User::find($userId) : null;
     return $user;
 }
开发者ID:greyexpert,项目名称:limoncello-shot,代码行数:10,代码来源:UserJwtCodec.php

示例2: testHandle

 public function testHandle()
 {
     $user = User::find(1);
     $message = '[l giraffes l] hey there boys [l big penis l] what do you feel like doing [l tonight l] [p penis p]';
     $ret = $this->dispatch(new ParseMessage($user, $message));
     $this->assertTrue($ret);
 }
开发者ID:keithyw,项目名称:bracket,代码行数:7,代码来源:ParseMessageTest.php

示例3: addMentions

 private static function addMentions($from)
 {
     if (!($targetNames = self::findMentions($from['text']))) {
         return false;
     }
     unset($from['text']);
     if (!($targets = User::find()->select('id')->where(['in', 'username', $targetNames])->asArray()->all())) {
         return false;
     }
     $topicAuthorNoticed = false;
     $topicAuthor = false;
     if (!empty($from['topic_author'])) {
         $topicAuthor = $from['topic_author'];
         unset($from['topic_author']);
     }
     foreach ($targets as $target) {
         if ($target['id'] == $from['source_id']) {
             continue;
         }
         if (!$topicAuthorNoticed && $topicAuthor && $target['id'] == $topicAuthor) {
             $topicAuthorNoticed = true;
         }
         $notice = new Notice($from);
         $notice->target_id = $target['id'];
         $notice->save(false);
     }
     return $topicAuthorNoticed;
 }
开发者ID:feijilei,项目名称:simpleforum,代码行数:28,代码来源:Notice.php

示例4: getUser

 public function getUser()
 {
     if ($this->_user == false) {
         $this->_user = User::find()->where(['telephone' => $this->telephone])->one();
     }
     return $this->_user;
 }
开发者ID:xiaojianxin,项目名称:Ontee,代码行数:7,代码来源:LoginForm.php

示例5: handle

 public function handle(UserDetailsQuery $query)
 {
     if (!is_null($query->username)) {
         return User::where('username', '=', $query->username)->first();
     }
     return User::find($query->userId);
 }
开发者ID:slice-beans,项目名称:cqs-framework,代码行数:7,代码来源:UserDetailsQueryHandler.php

示例6: postDeleteFriend

 public function postDeleteFriend($id)
 {
     $newUnFriendUser = User::find($id);
     $this->user->unfriend($newUnFriendUser);
     Flash::warning('You unfriended ' . $newUnFriendUser->name);
     return redirect('/');
 }
开发者ID:reportingsjr,项目名称:makerspace-manager,代码行数:7,代码来源:FriendshipController.php

示例7: getUser

 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = User::find()->where("username = :username ", [":username" => $this->username])->one();
     }
     return $this->_user;
 }
开发者ID:adsavin,项目名称:coolexam,代码行数:12,代码来源:LoginForm.php

示例8: actionAvatar

 public function actionAvatar()
 {
     $model = User::getUserInfo(Yii::$app->user->id);
     $this->layout = 'left_user_setting';
     if (Yii::$app->request->isPost) {
         $postAvatar = Yii::$app->request->post();
         $crop = new CropAvatar($postAvatar['avatar_src'], $postAvatar['avatar_data'], $_FILES['avatar_file']);
         $result = explode('.', $crop->getResult());
         $resultShow = '/' . $result['0'] . '_big.' . $result['1'];
         /*添加/进行输出*/
         $response = array('state' => 200, 'message' => $crop->getMsg(), 'result' => $resultShow);
         $model->file = $result['0'] . '.' . $result['1'];
         $model->save();
         echo json_encode($response);
         exit;
     }
     $userImage = explode('.', Yii::$app->user->getIdentity()->file);
     $userMiddleImage = $userImage['0'] . '_middle.' . $userImage['1'];
     $userBigImage = $userImage['0'] . '_big.' . $userImage['1'];
     return $this->render('avatarCropper', ['model' => $model, 'userMiddleImage' => $userMiddleImage, 'userBigImage' => $userBigImage]);
     $model = new CropAvatar();
     if (Yii::$app->request->isPost) {
         var_dump($_POST);
         exit;
         //$model->file = UploadedFile::getInstance($model, 'file');
     }
     $model = User::find()->one();
     if (empty($model)) {
         return $this->render('error', ['id' => Yii::$app->user->id]);
     }
     $this->layout = 'left_user_setting';
     return $this->render('avatar', ['model' => $model]);
 }
开发者ID:sayi21cn,项目名称:yt-for-coding,代码行数:33,代码来源:HomeController.php

示例9: postPartisipan

 public function postPartisipan($kelasId)
 {
     $response = [];
     $kelas = Kelas::find($kelasId);
     $gel = Gelombang::getActive();
     $response['errors'] = [];
     $response['kelas'] = $kelas;
     $response['gelombang'] = $gel;
     $response['validations'] = [];
     $response['fields'] = [];
     $response['actionLabel'] = 'Tambah';
     $response['output'] = view('backend.partials.master.kelas.partisipan', $response)->render();
     $input = $this->parseInput(request()->all());
     $input = $this->normaliseData($input);
     if (isset($input['_token'])) {
         $response['status'] = true;
         if (isset($input['partisipan'])) {
             foreach ($input['partisipan'] as $id => $useless) {
                 if (!$kelas->siswa->contains($id)) {
                     $kelas->siswa()->attach(User::find($id));
                 }
             }
         }
     }
     return $response;
 }
开发者ID:htwibowo,项目名称:simonev,代码行数:26,代码来源:KelasController.php

示例10: run

 public function run()
 {
     DB::table('roles')->truncate();
     DB::table('role_user')->truncate();
     DB::table('permissions')->truncate();
     DB::table('permission_role')->truncate();
     $admin_role = new Role();
     $admin_role->name = 'admin';
     $admin_role->display_name = 'Administrator';
     $admin_role->description = 'manages everything';
     $admin_role->save();
     $reviewer_role = new Role();
     $reviewer_role->name = 'reviewer';
     $reviewer_role->display_name = 'Reviewer';
     $reviewer_role->description = 'reviews inserted data';
     $reviewer_role->save();
     $inserter_role = new Role();
     $inserter_role->name = 'inserter';
     $inserter_role->display_name = 'Inserter';
     $inserter_role->description = 'inserts data about billboards';
     $inserter_role->save();
     $admin = User::find(1);
     $reviewer = User::find(2);
     $inserters = User::whereNotIn('id', [$admin->id, $reviewer->id])->get();
     $admin->attachRole($admin_role);
     $reviewer->attachRole($reviewer_role);
     foreach ($inserters as $user) {
         $user->attachRole($inserter_role);
     }
 }
开发者ID:sagaciresearch,项目名称:adtracking,代码行数:30,代码来源:RoleTableSeeder.php

示例11: getChat

 public function getChat($partner_id)
 {
     $user = Auth::user();
     $messages = $user->chat($partner_id);
     $partner = User::find($partner_id);
     return view('messages.chat')->with('messages', $messages)->with('user', $user)->with('partner', $partner);
 }
开发者ID:HenOltma,项目名称:EventMap,代码行数:7,代码来源:MessageController.php

示例12: user

 public function user($id)
 {
     $user = User::find($id);
     $prediction = new Prediction();
     $data = ["user" => $user, "predictions" => $prediction->make($user), "ratedMovies" => $prediction->getRatedmovies()];
     return view('user', $data);
 }
开发者ID:Vandrs,项目名称:topicos-avancados,代码行数:7,代码来源:PredictionController.php

示例13: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(\App\Http\Requests\UpdateUserRequest $request, $id)
 {
     $user = \App\Models\User::find($id);
     $user->fill($request->all());
     $user->save();
     return redirect("users/" . $user->id);
 }
开发者ID:skull213,项目名称:Klarity,代码行数:14,代码来源:UsersController.php

示例14: __construct

 /**
  * Create a new event instance.
  *
  * @return void
  */
 public function __construct($user_id, $game_id)
 {
     $user = \App\Models\User::find($user_id);
     $game_user = \App\Models\Game_User::where('user_id', $user_id)->where('game_id', $game_id)->first();
     $game_user['has_left'] = true;
     $game_user->save();
     $game_users = \App\Models\Game_User::where('game_id', $game_id)->get();
     $cont = 0;
     foreach ($game_users as $game_user) {
         if ($game_user['has_left']) {
             $cont++;
         }
     }
     $user_list = \App\Models\Game_User::where('game_id', $game_id)->get();
     $msg = 'El jugador ' . $user->first_name . ' se ha rendido';
     if ($cont == count($user_list) - 1) {
         $winner = \App\Models\Game_User::where('has_left', '=', false)->where('game_id', $game_id)->first();
         $winner['has_won'] = true;
         $winner->save();
         $winner_name = \App\Models\User::find($winner['user_id']);
         $msg .= ', y El jugador ' . $winner_name->first_name . ' ha ganado';
     }
     $games = \App\Models\Game_User::where('game_id', $game_id)->where('user_id', $user_id)->first();
     if (!$games['has_left']) {
         $letters_user = \App\Models\Letter_User::where('game_id', '=', $game_id)->where('user_id', $user_id)->get(['letter_id']);
         foreach ($letters_user as $key) {
             $user_letters_save = \App\Models\Inventory_Letter_Game::where('game_id', $game_id)->where('letter_id', $key->letter_id)->first();
             $user_letters_save->quantity++;
             $user_letters_save->save();
         }
     }
     $this->data = ['game_id' => $game_id, 'msg' => $msg];
 }
开发者ID:AndrewJey,项目名称:IIProyecto-Soft.Libre--Scrabble,代码行数:38,代码来源:GiveUp.php

示例15: sendrequest

 /**
  * Send an email to the user to request his confirmation for being a member of the team
  *
  * @return \Illuminate\Http\Response
  */
 public function sendrequest($plan_id, $id, AppMailer $mailer)
 {
     // check access rights
     if (!Auth::user()->ownsPlan($plan_id)) {
         return redirect('home')->with('error', 'You are unauthorized for this request.');
     }
     // get the resource handle
     $team = Team::find($id);
     if ($team) {
         if ($team->requested) {
             $error = 'Request Email was already sent to this user!';
             return \Redirect::back()->with(['error' => $error]);
         }
         $team->requested = True;
         $team->remember_token = str_random(32);
         // send internal message to user
         $message = 'Please open <a href="' . url('cspot/plans/' . $plan_id) . '/team"> this plan </a> and confirm if you accept the given role.';
         $thread_id = sendInternalMessage('You have been assigned a role in a Service plan', $message, $team->user_id, false);
         $team->thread_id = $thread_id;
         $team->save();
         // also send an email to the user
         $recipient = User::find($team->user_id);
         $plan = Plan::find($team->plan_id);
         $mailer->getPlanMemberConfirmation($recipient, $plan, $team);
         $status = 'Email with membership request was sent to user.';
         return \Redirect::route('team.index', ['plan_id' => $plan_id])->with(['status' => $status]);
     }
     $error = 'Wrong team member id!';
     return \Redirect::back()->with(['error' => $error]);
 }
开发者ID:matthiku,项目名称:cSpot,代码行数:35,代码来源:TeamController.php


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