Home > OS >  How to write double where with update in laravel
How to write double where with update in laravel

Time:08-07

how to write like this. this function is not working for me

ContractorsServices::where('serviceID',$request->id)->where('isPopular', false)->update([
    'isPopular' => true
]);

CodePudding user response:

try doing it this way

ContractorsServices::where(['serviceID' => $request->id, 'isPopular' => 'false'])
->update([
    'isPopular' => true
]);

CodePudding user response:

use:

ContractorsServices::where([
      ['serviceID',$request->id],
      ['isPopular', false]
    ])
    ->update([
       'isPopular' => true
    ]); 

if not work, check data is correct or not:

$ContractorsServices = ContractorsServices::where([
  ['serviceID',$request->id],
  ['isPopular', false]
])->get();

 return $ContractorsServices;
  • Related