本文整理汇总了PHP中Illuminate\Support\Facades\Auth::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::getUser方法的具体用法?PHP Auth::getUser怎么用?PHP Auth::getUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Auth
的用法示例。
在下文中一共展示了Auth::getUser方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postUpdate
public function postUpdate($id, Request $request)
{
$user = Auth::getUser();
if ($user->email == $request->get('email')) {
// user try to change own password
$validatorRules = ['password' => 'confirmed|min:6'];
} else {
// user try another email
$validatorRules = ['email' => 'required|email|max:255|unique:users', 'password' => 'confirmed|min:6'];
}
$this->validate($request, $validatorRules);
$data = $request->all();
// password crypt
if (isset($data['password'])) {
if (empty($data['password'])) {
unset($data['password']);
} else {
$data['password'] = bcrypt($data['password']);
}
}
$user = User::findOrFail($id);
$user->update($data);
Flash::success('Benutzerdaten sind aktualisiert.');
return redirect()->action('Auth\\EditController@getEdit');
}
示例2: panel
public function panel()
{
$user = Auth::getUser();
$rooms = $user->rooms()->wherePivot('owner', '=', 1)->get();
$rooms_foreign = $user->rooms()->wherePivot('owner', '=', 0)->get();
return view('panel', compact('rooms', 'rooms_foreign'));
}
示例3: getCurrentUserId
public function getCurrentUserId()
{
$user = Auth::getUser();
if (!is_null($user)) {
return $user->email;
} else {
return 'guest';
}
}
示例4: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$group = RoomGroup::with('room')->find($id);
$room = $group->room;
$user = Auth::getUser();
$isOwner = $room->checkIfUserIsOwner($user->id);
$comments = $group->comments()->paginate(5);
$comments->setPath(route('room.groups.show', [$room->id, $id]));
return view('group', compact('group', 'room', 'user', 'isOwner', 'comments'));
}
示例5: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('login');
}
} else {
if (Auth::getUser() and Auth::getUser()->type == 1) {
if (substr($request->path(), 0, 5) == 'admin') {
return redirect('/');
} else {
return $next($request);
}
} else {
return $next($request);
}
}
//return $next($request);
}
示例6: isJudged
public function isJudged($comment_id)
{
return $this->commentjudge->where('comment_id', $comment_id)->where('stu_id', Auth::getUser()->stu_id)->first() !== null;
}
示例7: join
public function join(Request $request)
{
$room = Room::code($request->input('code'))->first();
if (!$room) {
return redirect()->route('panel');
}
$user = Auth::getUser();
if (!in_array($room->id, $room->users->lists('id')->all())) {
$user->rooms()->attach($room->id);
}
return redirect()->route('rooms.show', $room->id);
}
示例8: getJobs
public function getJobs()
{
$jobs = Job::where("company_id", Auth::getUser()->company_id)->with(["company", "customer"]);
return view("jobs", ["jobs" => $jobs]);
}
示例9: postAddForumNewTopicAction
public function postAddForumNewTopicAction()
{
$user = Auth::getUser();
Page::create(array('title' => Input::get('title'), 'parent_id' => Input::get('parent_page_id'), 'is_sheet' => false, 'is_protected' => false));
/* ForumPageMessage::create(array(
'page_title' => Input::get('title'),
'content' => Input::get('content'),
'page_id' => Input::get('parent_page_id'),
'user' => $user->name,
));*/
return redirect('/admin/contents');
}
示例10: deleteFavorite
public function deleteFavorite($course_id)
{
return $this->favorite->where('course_id', $course_id)->where('stu_id', Auth::getUser()->stu_id)->delete();
}
示例11: authorize
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return Auth::getUser();
}