/** * [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; }
/** * [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; }