我正在尝试在“事务”表中创建新记录。并同时尝试更新另一个表。
这就是我所做的。
public function store(TransactionRequest $request, Item $item)
{
//this part works fine
Transaction::create([
'patron_id' => $request->patron_id,
'item_id' => $request->item_id,
'loaned' => $request->loaned,
'due' => $request->due,
]);
//THIS PART IS NOT WORKING
Item::find($request->item_id);
$item->update([
'onloan' => "1",
]);
return redirect(route('transactions.index'));
}
请帮忙。谢谢。
你可以试试这个
Item::find($request->item_id)
->update([
'onloan' => "1",
]);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句