示例#1
0
 /**
  * [handle description]
  *
  * @param  CartRepository $repository
  *
  * @return Cart
  */
 public function handle(CartRepository $repository, UserRepository $userRepository)
 {
     $user = $userRepository->find($this->user_id);
     $cart = new Cart($user);
     $repository->create($cart);
     return $cart;
 }
示例#2
0
 /**
  * [handle description]
  *
  * @param  UserRepository $repository
  *
  * @return User
  */
 public function handle(UserRepository $repository)
 {
     // Currently authenticated user
     //$user = app('Dingo\Api\Auth\Auth')->user();
     //$user->hasRoleByName('Member');
     //$user->hasRole($user->getRoles()->toArray());
     Assertion::currentUserIsAdmin('You have no permission to create an Item');
     $user = $repository->get($this->id);
     Assertion::entityExists($user, "User with ID '{$this->id}' not found");
     return $user;
 }
 public function boot(UserRepository $repository)
 {
     $this->app[Auth::class]->extend('oauth', function ($app) use($repository) {
         $provider = new OAuth2($app['oauth2-server.authorizer']->getChecker());
         $provider->setUserResolver(function ($id) use($repository) {
             // Logic to return a user by their ID.
             return $repository->get($id);
         });
         /*$provider->setClientResolver(function ($id) {
               // Logic to return a client by their ID.
               return new \stdClass;
           });*/
         return $provider;
     });
 }
 public function handle(UserRepository $repository, RoleRepository $roleRepository)
 {
     $user = new User();
     $user->firstname = $this->firstname;
     $user->lastname = $this->lastname;
     $user->password = bcrypt($this->password);
     $user->contact = new Contact($this->email);
     // Add default Member Role
     // 1 => Admin
     // 2 => Member
     $role = $roleRepository->find(2);
     $user->addRole($role);
     $repository->create($user);
     // Call Cart API to create a cart for this user
     $cart = $this->dispatcher->post('carts', ['user_id' => $user->id]);
     return $user;
 }
示例#5
0
 /**
  * [handle description]
  *
  * @param  EntityManager $em
  *
  * @return User
  */
 public function handle(UserRepository $repository)
 {
     return $repository->all();
 }