I have the status attribute in my class. When creating a new instance, using 'create', I pass an array to the status.
class email extends Eloquent{
protected $table = 'emails';
protected $fillable = array(
'status',
);
}
And this is the result
"status": {
"sent": false,
"deleted": false,
"silent": false
}
I'm trying to do this to update only one of the statuses.
$dest= email::where('uid', "5040")->update(['status.sent'=>true]);
But this produces a result I would not like.
"status": {
"sent": true
}
All previously written content has been deleted, how to get this result.
"status": {
"sent": true,
"deleted": false,
"silent": false
}
I have an idea of querying the bank and getting the status array, storing it, changing it, and updating it, but that would make me query the bank twice. One fetching the array, the other updating. There is a way, like 'spread'(...). Or something more correct and simple.
EDIT: In my case, to work, change John Lobo's solution,
'array' to 'text' and update(['status->sent'=>true]) to update(['status.sent'=>true]);
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire