本文整理汇总了PHP中App\Repositories\UserRepository::find方法的典型用法代码示例。如果您正苦于以下问题:PHP UserRepository::find方法的具体用法?PHP UserRepository::find怎么用?PHP UserRepository::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Repositories\UserRepository
的用法示例。
在下文中一共展示了UserRepository::find方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ban
/**
* Ban user
*
* @param Request $request
* @param $user
* @return Redirect
*/
public function ban(Request $request, $user)
{
$userToBan = $this->users->find($user);
$userToBan->banned = 1;
$userToBan->save();
return redirect('/posts');
}
示例2: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$user = $this->userRepository->find($this->authorizer->getResourceOwnerId());
App::singleton('user', function () use($user) {
return $user->toArray();
});
return $next($request);
}
示例3: loginByCookie
public function loginByCookie($cookie)
{
$user = $this->createOrUpdateUserByCookie($cookie);
// Login
$this->guard->login($user, true);
// Return an actual user model if login passes
if ($this->guard->check()) {
return $this->userRepository->find($this->guard->id());
} else {
$errorMessage = 'Login error. User is not authorized. (binary_id: ' . $user->binary_id . ')';
Log::error($errorMessage);
throw new AuthException($errorMessage);
}
}
示例4: update
/**
* @param $id
* @param UpdateUserRequest $request
*/
public function update(UpdateUserRequest $request, $id)
{
$user = $this->user->find($id);
$user->email = $request->get('email');
if ($request->get('password')) {
$user->password = $request->get('password');
}
$user->save();
if ($request->get('role')) {
$user->roles()->sync($request->get('role'));
} else {
$user->roles()->sync([]);
}
Flash::success('User successfully updated');
return redirect('/users');
}
示例5: handle
/**
* Execute the job.
*
* @return void
*/
public function handle(UserRepository $userRepository)
{
$user = $userRepository->find($this->user['id']);
if (!Hash::check($this->params['old_password'], $user->password)) {
throw new PasswordNotMatch();
}
$password = bcrypt($this->params['password']);
return $userRepository->update($this->user['id'], ['password' => $password]);
}
示例6: destroy
/**
* Remove the specified User from storage.
*
* @param int $id
*
* @return Response
*/
public function destroy($id)
{
$user = $this->userRepository->find($id);
if (empty($user)) {
Flash::error('User not found');
return redirect(route('users.index'));
}
$this->userRepository->delete($id);
Flash::success('User deleted successfully.');
return redirect(route('users.index'));
}
示例7: disableSelected
/**
* @return \Illuminate\View\View
*/
public function disableSelected(Request $request)
{
$chkUsers = $request->input('chkUser');
if (isset($chkUsers)) {
foreach ($chkUsers as $user_id) {
$user = $this->user->find($user_id);
if (!$user->canBeDisabled()) {
Flash::error(trans('admin/users/general.error.cant-be-disabled'));
} else {
$user->enabled = false;
$user->save();
}
}
Flash::success(trans('admin/users/general.status.global-disabled'));
} else {
Flash::warning(trans('admin/users/general.status.no-user-selected'));
}
return redirect('/admin/users');
}
示例8: create
public function create($id, UserRepository $userRepository, Auth $auth)
{
$data = ['user' => $userRepository->find($id), 'authUser' => $auth->user()];
return View('transactions.new')->with($data);
}
示例9: getInfo
/**
* @param Request $request
* @return mixed
*/
public function getInfo(Request $request)
{
$id = $request->input('id');
$user = $this->user->find($id);
return $user;
}
示例10: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
*
* @return \Illuminate\View\View
*/
public function edit($id)
{
$user = $this->users->find($id);
return view('backend.users.edit', compact('user'));
}
示例11: show
/**
* Display the specified resource.
*
* @param int $id
*
* @return Response
*/
public function show($id)
{
$user = $this->repo->find($id);
return view('');
}
示例12: handle
/**
* Execute the job.
*
* @return void
*/
public function handle(UserRepository $userRepository)
{
$user = $userRepository->find($this->user['id']);
return $user;
}