No problem, rewrite your check to another where condition
Jul 11, 2022
9
Level 4
laravel update query if else
Hello It is possible make check inside update query I want make update 'priceA' if $checkPrice is more 100
Post::where('id', 1)
->update([
'title' => $title;
'text' => $text;
if( $checkPrice > 100) { 'priceA'=> $priceA }
]);
Level 75
Post::where('id', 1)->update([
'title' => $title,
'text' => $text
] + ($checkPrice > 100 ? [
'priceA'=> $priceA
] : []));
4 likes
Please or to participate in this conversation.