I am updating my ClaimCommission table but at the same time i would like to update also the columns from my commission table which has conditions.
(我正在更新我的ClaimCommission表,但同时我也想更新我的有条件的佣金表中的列。)
here's my update function. (这是我的更新功能。)
public function update(Request $request, $id)
{
$archive = (isset($request->archive) == '1' ? '1' : '0');
$approve = (isset($request->approve) == '1' ? '1' : '0');
$claimcommission = ClaimCommission::findOrFail($id);
$claimcommission->update([
'date_approval' => $request->date_approved,
'archive' => $archive,
'approve' => $approve
]);
// THIS IS MY ISSUES. I WANTED TO UPDATE THE PAID AND CLAIMED COLUMN FROM COMMISSIONS TABLE
if($request->approve == 'on'){
$user_id = $request->user_id;
$commissions = Commissions::where('user_id', $user_id)
->where('paid','=',0)
->where('claimed','=',1)
->update([
'paid' => 1,
'claimed' => 0
]);
}
return redirect('dashboard/claim-commission')->with('success', 'Completed!');
}
what do you think the problem is?
(您认为问题是什么?)
thanks in advance! (提前致谢!)
ask by Lito translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…