mardi 19 novembre 2019

Laravel provide different result when using where condition with update

Condition 1:

$update=Model:orWhere(..)->orWhere(..)->update([$updateField => "1"]);
if($update==1)

this return an integer value as 0 and 1 things works fine

Condition 2:

 $update=Model:where(..)->orWhere(..)->orWhere(..)->update([$updateField => "1"]);
 if($update==1)

Gives error

Object of class Illuminate\Database\Eloquent\Collection could not be converted to int

Also tried

 Model:where(function($q) use(..) {
            return $q
                     ->where(..)
                     ->orWhere(..);
          })->where(..)->update([$updateField => "1"]);

Also returns an object rather integer while updating, facing strange response from update function.

Any Help would be great



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire