本文整理汇总了PHP中App\Http\Controllers\Auth::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::getUser方法的具体用法?PHP Auth::getUser怎么用?PHP Auth::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Http\Controllers\Auth
的用法示例。
在下文中一共展示了Auth::getUser方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAuthenticatedUser
/**
* @author WN
* @return \App\User
* @throws ModelNotFoundException
*/
protected function getAuthenticatedUser()
{
if (\Auth::getUser()) {
return \Auth::getUser();
}
throw new ModelNotFoundException('Authenticated user not found');
}
示例2: getlaporan
public function getlaporan()
{
if (\Auth::check() && \Auth::getUser()->getAttribute('admin') == 1) {
$orders = \DB::table('order')->get();
return view('admin.home', compact('orders'));
} else {
return redirect('home');
}
}
示例3: disabled
/**
* Аккаунт не активен
*/
public function disabled()
{
$user = \Auth::getUser();
if ($user->is_active) {
return redirect(route('profile'));
} else {
return view('user/disabled')->with(['user' => $user]);
}
}
示例4: update
/**
* Сохранить свой Профиль
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function update(Request $request)
{
$user = \Auth::getUser();
$user->fill($request->all());
$validator = \Validator::make($user->getAttributes(), $rules = self::getValidatorRules($user->id));
if ($validator->fails()) {
$this->throwValidationException($request, $validator);
}
$user->save();
return redirect('profile');
}
示例5: store
/**
* Добавить коммент
*
* @param \Illuminate\Http\Request $request
* @param $id
* @return \Illuminate\Http\Response
*/
public function store(Request $request, $id)
{
$contact = \App\Contact::findOrFail($id);
$data = $request->input();
$validator = \Validator::make($data, $rules = self::getValidatorRules());
if (!$validator->fails()) {
$model = new ContactLog($request->input());
$model->user_id = \Auth::getUser()->id;
$model->contact_id = $contact->id;
$model->save();
}
return redirect(route('contact.show', $contact));
}
示例6: myAccount
/**
* get user details and display
*/
public function myAccount()
{
$user = Auth::getUser();
return View::make('user_account', compact('user'));
}
示例7: status
/**
* Изменить Статус
*
* @param \Illuminate\Http\Request $request
* @param $id
* @param $status
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function status(Request $request, $id, $status)
{
/** @var Contact $contact */
$contact = Contact::findOrFail($id);
// TODO: проверка, что пользователю разрешен перевод в выбранный статус
if ($contact->status != $status) {
$contact->status = $status;
$contact->change_status_comment = $request->get('comment');
switch ($status) {
case \App\Contact::STATUS_WORK:
case \App\Contact::STATUS_SUCCESS:
$contact->taken_by = \Auth::getUser()->id;
$contact->taken_at = new \DateTime();
break;
case \App\Contact::STATUS_FAIL:
if (!$contact->change_status_comment) {
Flash::error('Укажите причину отказа');
goto redirect;
}
//break;
//break;
case \App\Contact::STATUS_NEW:
$contact->taken_by = null;
$contact->taken_at = null;
break;
default:
goto redirect;
}
$contact->save();
}
redirect:
return redirect(route('contact.show', $contact));
}