protected function authenticated()
 {
     $id = Auth::id();
     $user = User::find($id);
     if ($user->role == 'Admin') {
         return redirect('/admin');
     }
     return redirect('/admin');
 }
Ejemplo n.º 2
0
 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');
 }
Ejemplo n.º 3
0
 /**
  * @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);
 }
Ejemplo n.º 4
0
 /**
  * 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'];
     }
 }
Ejemplo n.º 5
0
 /**
  * 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'));
     }
 }