当前位置: 首页>>代码示例>>PHP>>正文


PHP Auth::id方法代码示例

本文整理汇总了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');
 }
开发者ID:safieurrahman,项目名称:Web-Engineering-Assignment-3,代码行数:9,代码来源:AuthController.php

示例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');
 }
开发者ID:utkarsh578,项目名称:obscura-2016,代码行数:9,代码来源:AuthController.php

示例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);
 }
开发者ID:nvisser,项目名称:sportschool,代码行数:29,代码来源:AuthController.php

示例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'];
     }
 }
开发者ID:ThapaMahesh,项目名称:locker,代码行数:34,代码来源:AuthController.php

示例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'));
     }
 }
开发者ID:jasonjyu,项目名称:cscie15-p4,代码行数:14,代码来源:AuthController.php


注:本文中的App\Http\Controllers\Auth\Auth::id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。