public function add($itemID, $name = null, $qty = 1, $price = '0.00', $options = [], $taxable = true, $lineItem = false)
{
if (!empty(config('laracart.item_model'))) {
$itemModel = $itemID;
if (!$this->isItemModel($itemModel)) {
$itemModel = (new $this->itemModel())->with($this->itemModelRelations)->find($itemID);
}
if (empty($itemModel)) {
throw new ModelNotFound('Could not find the item ' . $itemID);
}
$bindings = config('laracart.item_model_bindings');
$itemID = $itemModel[$bindings[\LukePOLO\LaraCart\CartItem::ITEM_ID]];
$name = $itemModel[$bindings[\LukePOLO\LaraCart\CartItem::ITEM_NAME]];
if (empty($qty = $name) || !is_int($name)) {
$qty = 1;
}
$price = $itemModel[$bindings[\LukePOLO\LaraCart\CartItem::ITEM_PRICE]];
$options = array_merge($options, $this->getItemModelOptions($itemModel, $bindings[\LukePOLO\LaraCart\CartItem::ITEM_OPTIONS]));
$taxable = $itemModel[$bindings[\LukePOLO\LaraCart\CartItem::ITEM_TAXABLE]] ? true : false;
}
$item = $this->addItem(new CartItem($itemID, $name, $qty, $price, $options, $taxable, $lineItem));
$this->update();
return $this->getItem($item->getHash());
}