mardi 8 mai 2018

Laravel Jenssegers: Invalid key 'updated_at': update only works with $ operators

I am trying to update the my array field named interest with the array that contain the values using the Model. But It shows me error regarding some timestamp field updated_at.

the Query i am using is as follow

User::where('user_id',$user_id)->update(['$addToSet' => ['interest'=> ['$each'=>$arrayToBeInserted]]]);

Above Query Shows the Following Error:

enter image description here

But If i am using the DB namespace instead of Model then it works fine by following query:

    DB::table('users')->where('user_id',$user_id)->update(['$addToSet' => ['interest'=> ['$each'=>$array]]]);

It shows the error regarding the updated_at field but I don't know why it is not working with the Model Query.

any help will be appreciated. Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire