Example #1
0
 /**
  * [handle description]
  *
  * @param  CartRepository $repository
  *
  * @return Cart
  */
 public function handle(CartRepository $repository, InventoryItemRepository $itemRepository)
 {
     $inventoryItem = $itemRepository->get($this->item_id);
     $cart = $repository->get($this->cart_id);
     Assertion::notNull($cart, 'Invalid shopping cart');
     Assertion::notNull($inventoryItem, 'Invalid item to purchase');
     $item = $cart->addItem($inventoryItem, $this->quantity);
     $repository->update($cart);
     return $item;
 }
Example #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;
 }
Example #3
0
 /**
  * [handle description]
  *
  * @param  UserRepository $repository
  *
  * @return User
  */
 public function handle(ItemRepository $repository)
 {
     $item = $repository->get($this->id);
     Assertion::entityExists($item, "Item with ID '{$this->id}' not found");
     return $item;
 }