Example #1
0
 /**
  * Find the user by the given email address.
  *
  * @param  int  $email
  * @return \Begin\User
  */
 public function findByEmail($email)
 {
     $user = $this->model->where('email', $email)->first();
     if (is_null($user)) {
         throw new UserNotFoundException("The user with id as {$id} does not exist.");
     }
     return $user;
 }
Example #2
0
 /**
  * Boot the authentication services for the application.
  *
  * @return void
  */
 public function boot()
 {
     // Here you may define how you wish users to be authenticated for your Lumen
     // application. The callback which receives the incoming request instance
     // should return either a User instance or null. You're free to obtain
     // the User instance via an API token or any other method necessary.
     Auth::viaRequest('api', function ($request) {
         if ($request->input('api_token')) {
             return User::where('api_token', $request->input('api_token'))->first();
         }
     });
 }
Example #3
0
 /**
  * Find all completed tasks for the given user.
  *
  * @param  \Begin\User $user
  * @return \Begin\Task[]
  */
 public function findAllCompletedForUser(User $user)
 {
     $tasks = $user->tasks()->where('completed', true)->orderBy('created_at', 'desc')->get();
     return $tasks;
 }