本文整理汇总了PHP中App\Http\Controllers\Auth\Auth::id方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::id方法的具体用法?PHP Auth::id怎么用?PHP Auth::id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Http\Controllers\Auth\Auth
的用法示例。
在下文中一共展示了Auth::id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticated
protected function authenticated()
{
$id = Auth::id();
$user = User::find($id);
if ($user->role == 'Admin') {
return redirect('/admin');
}
return redirect('/admin');
}
示例2: logout
public function logout()
{
if (Users::getUserMaxLevel(Auth::id()) == 6) {
Users::updateLevel(6);
}
Auth::logout();
Session::flush();
return Redirect::to("/login")->with('message', 'Successfully you are logged-out');
}
示例3: stats
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function stats()
{
$user = \Auth::id();
$now = new Carbon();
$currentFirstDay = clone $now;
$currentFirstDay = $currentFirstDay->firstOfMonth();
$currentLastDay = clone $now;
$currentLastDay = $currentLastDay->lastOfMonth();
$thisMonth = Checkin::where('user_id', $user)->whereBetween('checkin', [$currentFirstDay, $currentLastDay])->whereBetween('checkout', [$currentFirstDay, $currentLastDay])->orderBy('checkout')->get();
$stats['current']['total'] = $thisMonth->sum('burned');
$stats['current']['min'] = $thisMonth->min('burned');
$stats['current']['max'] = $thisMonth->max('burned');
$previousLastDay = clone $currentFirstDay;
$previousLastDay = $previousLastDay->modify('-1 day');
$previousFirstDay = clone $previousLastDay;
$previousFirstDay = $previousFirstDay->firstOfMonth();
$previousMonth = Checkin::where('user_id', $user)->whereBetween('checkin', [$previousFirstDay, $previousLastDay])->whereBetween('checkout', [$previousFirstDay, $previousLastDay])->orderBy('checkout')->get();
$stats['previous']['total'] = $previousMonth->sum('burned');
$stats['previous']['min'] = $previousMonth->min('burned');
$stats['previous']['max'] = $previousMonth->max('burned');
if ($stats['current']['total'] < $stats['previous']['total']) {
$stats['difference'] = $stats['previous']['total'] - $stats['current']['total'];
$stats['suggestion'] = Equipment::orderBy('calories_pm', 'desc')->first();
}
return view('equipment.progress', $stats);
}
示例4: postRegister
/**
* Store the member information
*
* @return success message
* @param name, email, password
*/
public function postRegister(Register $request, User $user)
{
try {
$user->name = $request->input('name');
$user->email = $request->input('email');
$user->password = bcrypt($request->input('password'));
$name = $user->name;
$email = $user->email;
if ($user->save()) {
// \Mail::send('emails.welcome', ['name' => $name], function($message) use($email, $name){
// $message->to($email, $name)->subject('Welcome!');
// });
$credentials = ['email' => $user->email, 'password' => $request->input('password')];
if (\Auth::attempt($credentials, false)) {
if ($request->has('browser')) {
return redirect($this->loginPath())->withInput($request->only('email', 'name'))->withErrors(['error' => $this->getFailedLoginMessage()]);
}
return ['message' => 'Login Success!!', 'data' => \Auth::id(), 'code' => '200'];
}
}
if ($request->has('browser')) {
return redirect($this->loginPath())->withInput($request->only('email', 'name'))->withErrors(['error' => $this->getFailedLoginMessage()]);
}
return ['message' => 'Login Failure!!', 'data' => '', 'code' => '401'];
} catch (\Exception $e) {
return ['message' => 'Login Failure!!', 'data' => $e->getMessage(), 'code' => '401'];
}
}
示例5: saveStoredHashtags
/**
* Saves the hashtag terms stored in the global session to the database.
*/
protected function saveStoredHashtags()
{
// get the user id logged in
$user_id = \Auth::id();
// create a hashtag associated with the user if it does not exist
// for each stored hashtag term in global session
$stored_terms = \Session::pull('stored_terms', []);
while (($term = array_pop($stored_terms)) != null) {
\App\Hashtag::firstOrCreate(compact('term', 'user_id'));
}
}