Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
504 views
in Technique[技术] by (71.8m points)

laravel - 布尔字段未从Laravel中的复选框值更新(Boolean field is not updating from checkbox value in Laravel)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...