本文整理汇总了PHP中App\Model\User::find方法的典型用法代码示例。如果您正苦于以下问题:PHP User::find方法的具体用法?PHP User::find怎么用?PHP User::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Model\User
的用法示例。
在下文中一共展示了User::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUser
/**
* @return User
*/
public function getUser()
{
if (empty($this->user) && !empty($this->user_id)) {
$this->user = User::find($this->user_id);
}
return $this->user;
}
示例2: user
public function user($id)
{
$user = \App\Model\User::find($id);
$posts = $user->posts()->paginate(25);
$s = $user->name;
return view('post/list')->with('posts', $posts)->with('type', ['name' => 'tag', 'title' => "\"{$s}\"发表"]);
}
示例3: send
public function send($id, UserMessage $userMessage, User $user)
{
$curUserId = $this->current_user->id;
$userPage = $user->find($id);
$userMsg = $userMessage->where('user_id', '=', $curUserId)->where('user_send_id', '=', $id)->with('user')->with('userSend')->get();
return view('pages.messages.send', compact('userPage', 'userMsg'));
}
示例4: index
public function index(string $jwt, string $url = '')
{
if ($payload = $this->jwtEx->decode($jwt)) {
if ($user_id = $payload->user_id ?? 0) {
if ($user = User::find($user_id)) {
if (!empty($payload->authorize)) {
/** @var User $user */
if ($user->verified == 'n') {
$user->ip_addr = $this->sniffer->getUserIP();
$user->verified = 'y';
$user->save();
}
$this->session->startSession($user_id);
}
if (!empty($payload->eventName)) {
$event = new UserEvent($user_id, $user->toArray());
$event->setData($payload->eventData ?? '');
$this->dispatcher->fire($payload->eventName, $event);
}
}
}
} else {
$params = ['msg' => 'Sorry this link has expired'];
}
return new Redirection($url ?: '/', $params ?? []);
}
示例5: become
/**
* Become a user without having to login.
*/
public function become($username)
{
$user = User::find($username);
if ($user) {
$this->user = $user;
$_SESSION['username'] = $user;
}
}
示例6: changePassword
/**
* Change user password
* POST
*
* @param Request $request
* @return Response
*/
public function changePassword(Request $request)
{
$this->validate($request, ['oldPass' => 'required|alpha_num|exists:accounts,pass,guid,' . Auth::user()->guid, 'answer' => 'required|exists:accounts,reponse,guid,' . Auth::user()->guid, 'newPass' => 'required|alpha_num|min:4']);
$user = UserManager::find(Auth::user()->guid);
$user->pass = $request->newPass;
$user->save();
return redirect()->route('profile');
}
示例7: user_tasks
public function user_tasks($uid)
{
$user = User::find($uid);
if (empty($user)) {
abort(404);
} else {
var_dump($user->tasks);
}
}
示例8: show
public function show($id = null)
{
$user = User::find($id);
if (!$user->isCurrent()) {
die;
}
$this->viewData['user'] = $user;
return view('profiles.show', $this->viewData);
}
示例9: confirmPaiement
/**
* Buy points
* POST
*
* @param Request $request
* @return Response
*/
public function confirmPaiement(Request $request)
{
$this->validate($request, ['code' => 'required|alpha_num']);
$dedipass = json_decode(file_get_contents('http://api.dedipass.com/v1/pay/?public_key=' . config('config.dedipass.public') . '&private_key=' . config('config.dedipass.private') . '&code=' . $request->code));
if ($dedipass->status != 'success') {
return redirect()->back();
}
$user = UserManager::find(Auth::user()->guid);
$user->points += config('config.points.buy');
$user->save();
return redirect()->route('home');
}
示例10: update
public function update($email, $password)
{
if (!empty($email) && !empty($password) && filter_var($email, FILTER_VALIDATE_EMAIL)) {
if ($user = User::find($this->session->getLoggedInUserId())) {
$event = new UserUpdateDataEvent($user, ['email' => $email, 'password' => $password]);
$this->dispatcher->fire(UserUpdateDataEvent::USER_UPDATE_DATA, $event);
if ($event->isHandled()) {
return 'pass';
}
}
}
throw new UserUpdateDataError("Unable to update credentials");
}
示例11: iron
/**
* php artisan queue:listen --queue=TestQue
*/
public function iron()
{
// $ironmq = new IronMQ(array(
// 'project_id' => env('IRON_PROJECT_ID'),
// 'token' => env('IRON_TOJEN'),
// 'host' => env('IRON_HOST')
// ));
// $ironmq->ssl_verifypeer = false;
// $ironmq->postMessage(env('IRON_QUEUE'), "Test Message FROM " . __CLASS__ . ':' . __FUNCTION__);
$job = with(new SendReminderEmail(User::find(89)))->onQueue(env('IRON_QUEUE'))->delay(15);
$this->dispatch($job);
return __CLASS__ . ':' . __FUNCTION__ . ':' . env('IRON_QUEUE');
}
示例12: userData
public function userData($userData, $userId)
{
$user = User::find($userId);
//Check if user exist
if (!$user) {
$user = new User();
}
$user->name = $userData['name'];
$user->email = $userData['email'];
$user->password = Hash::make($userData['password']);
$user->save();
return $user;
}
示例13: confirmCode
/**
* Confirm code and give reward
* POST
*
* @param Request $request
* @param string $key
* @return Response
*/
public function confirmCode(Request $request, $key)
{
$user = UserManager::find(Auth::user()->guid);
$code = CodeManager::find($key);
$code->use -= 1;
$code->accounts .= $user->guid . '|';
$code->save();
switch ($code->action) {
case 1:
//Give points
$user->points += $code->param;
$user->save();
break;
case 2:
//Give tokens
$token = \App\Model\TokensAccount::where('guid', $user->guid)->where('token', $code->param)->first();
if (!$token) {
$token = new \App\Model\TokensAccount();
$token->guid = $user->guid;
$token->token = $code->param;
$token->quantity = 1;
} else {
$token->quantity += 1;
}
$token->save();
break;
case 3:
//Give item
$this->validate($request, ['player' => 'required|numeric|exists:personnages,guid']);
$this->GiveObject($request->player, $code->param);
break;
case 4:
//Give itemsets
$this->validate($request, ['player' => 'required|numeric|exists:personnages,guid']);
$itemset = \App\Model\Itemset::find($code->param);
$exp = explode(',', $itemset->items);
foreach ($exp as $id) {
$this->_giveObject($request->player, $id);
}
break;
}
if ($code->use == 0) {
$code->delete();
}
return redirect()->route('gift.code');
}
示例14: index
public function index($_params)
{
if (!empty($_params['password'])) {
if ($user = User::find($this->session->getLoggedInUserId())) {
$event = new UserUpdateDataEvent($user, ['password' => $_params['password']]);
$this->dispatcher->fire(UserUpdateDataEvent::USER_UPDATE_DATA, $event);
if ($event->isHandled()) {
return json_encode(['update' => 'PASSWORD_RESET']);
} else {
throw new UserUpdateDataError($event->getError() ?: 'UNKNOWN_ERROR');
}
} else {
throw new UserUpdateDataError('UNKNOWN_USER');
}
} else {
throw new UserUpdateDataError('INVALID_DATA');
}
}
示例15: index
public function index(int $ar_list_id)
{
$user_ids = $this->listManager->getTargetUserIds($ar_list_id);
$out = fopen('php://output', 'w');
$this->response->asFile(sprintf('ar_download_list_%d.csv', $ar_list_id), 'text/csv');
/** @var User $user */
foreach (User::find($user_ids ?? [0]) as $user) {
$attrs = $user->attributesToArray();
unset($attrs['password']);
unset($attrs['ident']);
if (empty($header)) {
$header = true;
fputcsv($out, array_keys($attrs));
}
fputcsv($out, $attrs);
}
fclose($out);
}