本文整理汇总了PHP中app\User::load方法的典型用法代码示例。如果您正苦于以下问题:PHP User::load方法的具体用法?PHP User::load怎么用?PHP User::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\User
的用法示例。
在下文中一共展示了User::load方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$this->config = new Config();
$this->db = new \App\Db();
// User.
$this->user = new User($this->db);
if (isset($_SESSION['userid'])) {
$this->user->load($_SESSION['userid']);
}
}
示例2: updateRoles
/**
* Assign permissions to user
*/
public function updateRoles(Request $request, User $user)
{
$roles = $request->checkedRoles ?: [];
// $roles = array of submitted roles OR if all checkboxes were unchecked, make it an empty array
$user->roles()->sync($roles);
logThis('Roles for ' . $user->name . ' changed to ' . $user->roles()->lists('label'));
return $user->load('roles');
}
示例3: makeClientToken
public function makeClientToken(User $user)
{
$user->load('oauth_client');
if (!$user->oauth_client) {
$client_id = $this->createOauthClient(false, false, $user->email, false, $user->id);
} else {
$client_id = $user->oauth_client->id;
}
$session_id = $this->createSession(false, $client_id, $user, 'client');
$token_id = $this->createAccessToken(false, $session_id);
return $token_id;
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$user = new User();
$user->first_name = $request->input('first_name');
$user->middle_name = $request->has('middle_name') ? $request->input('middle_name') : '';
$user->last_name = $request->input('last_name');
$user->phone = $request->has('phone') ? $request->input('phone') : '';
$user->email = $request->input('email');
$user->user_name = $request->input('user_name');
$user->role = $request->input('role');
$user->password = Hash::make($request->input('password'));
$user->recipient_id = $request->input('recipient_id');
$user->save();
Log::create(array("user_id" => Auth::user()->id, "action" => "Add user named " . $user->first_name, " " . $user->last_name));
return $user->load('recipient', 'roles');
}
示例5: edit
/**
* Show the form for editing the specified resource.
*
* @param User $user
* @param \App\Classes\Rank $rank,
* @param \App\Classes\Country $country,
* @return \Illuminate\Http\Response
*/
public function edit(User $user, Rank $rank, Country $country)
{
$user->load('categories');
return view('admin.user.edit', ['user' => $user, 'ranks' => $rank->getRanks(), 'countries' => $country->getCountries(), 'reviewer' => 1, 'selectedCategories' => $user->categories->lists('id')->toArray(), 'categories' => getNomenclatureSelect($this->getCategories($user->department_id))]);
}
示例6: pushUser
/**
* Create a new user from request.
*
* @param $request input form data
* @return User
*/
public function pushUser($request)
{
$input = $request->all();
$secret = $input['password'];
$input['password'] = Hash::make($input['password']);
$user = new User();
$user->fill($input);
$user->save();
$user->role()->attach(1);
$user->load('role');
//$this->sendWelcome($user, $secret);
return $user;
}
示例7: show
/**
* Display the specified resource.
*
*
* @param User $user
*
* @return Response
*/
public function show(User $user)
{
$user->load('orders', 'orders.products');
$orders = $user->orders()->get();
return view('users.show', compact('user', 'orders'));
}
示例8: show
public function show(User $user)
{
$user->load('biography', 'contactDetails', 'address', 'profile', 'artwork');
return view('frontend.pages.user.show', compact('user'));
}
示例9: remindReset
public function remindReset(Request $request, Response $response, array $args)
{
$template = new \App\Template('remind_reset.twig');
// First check that the passwords match.
$password = $request->get('password');
if ($password !== $request->get('password-confirmation')) {
$template->alert('warning', 'Your passwords did not match.', true);
return new RedirectResponse($this->config->baseUrl() . "/remind/" . $args['userid'] . "/" . $args['token']);
}
// Then see if the token is valid.
$user = new User($this->db);
$user->load($args['userid']);
if (!$user->checkReminderToken($args['token'])) {
$template->alert('warning', 'That reminder token has expired. Please try again.', true);
return new RedirectResponse($this->config->baseUrl() . "/remind");
}
// Finally change the password. This will delete the token as well.
$user->changePassword($password);
$template->alert('success', 'Your password has been changed. Please log in.', true);
return new RedirectResponse($this->config->baseUrl() . "/login?name=" . $user->getName());
}
示例10: setGroup
/**
* @param \App\User $user
* @param \App\Group $group
* @return $this
*/
public function setGroup(\App\User $user, \App\Group $group)
{
$user->group()->associate($group);
$user->load('group');
return $this;
}