我试图使用雄辩的模型从数据库中减去一个值,而我似乎无法让它发挥作用。
以下是我现在所拥有的:
public function store()
{
$sku = Input::get('sku');
$quantitysold = Input::get('quantitysold');
$inventory = Inventory::where('sku', $sku)->decrement('sku', $quantitysold);
$inventory->save();
$transaction = new Transaction;
$transaction->sku = $sku;
$transaction->quantitysold = $quantitysold;
$transaction->save();
return 'Item has been saved';
}
当我尝试修补时,我得到以下内容:
PHP Fatal error: Call to a member function save() on a non-object