本文整理汇总了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;
}
示例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);
}
示例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;
}
示例4: getUser
public function getUser()
{
if ($this->_user == false) {
$this->_user = User::find()->where(['telephone' => $this->telephone])->one();
}
return $this->_user;
}
示例5: handle
public function handle(UserDetailsQuery $query)
{
if (!is_null($query->username)) {
return User::where('username', '=', $query->username)->first();
}
return User::find($query->userId);
}
示例6: postDeleteFriend
public function postDeleteFriend($id)
{
$newUnFriendUser = User::find($id);
$this->user->unfriend($newUnFriendUser);
Flash::warning('You unfriended ' . $newUnFriendUser->name);
return redirect('/');
}
示例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;
}
示例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]);
}
示例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;
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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];
}
示例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]);
}