Hi, thanks for helping me.
I have the following problem. I need to update a json that has the following structure.
"Configuracion": {
"Estados": {
"Idioma": "es",
"ComponenteActual": "datos-personales_2",
"ProgresoDeBarra": {
"Avance": 0,
"Puntos": {
"P_1": {
"NumeroDePerguntas": 5,
"NombreDeSeccion": "Tu perfil",
"NombreDeComponente": "datos-personales_1"
},
}
}
},
"Formulario": {
"NombreDelComponenteAnterior": null,
"NombreDelComponentePosterior": "datos-personales_2",
"Preguntas": {
"p_1": {
"Correo_profesional": "",
"Nombre": "",
"Apellidos": "",
"Edad": "",
"Genero": ""
}
}
}
}
I am using eloquent to consume my mongo database and I do it in the following way.
$modelo = Mymodelo::where('_id','=',$registro)->first();
Obviously this retrieves the first json, then to modify it I do the following.
$modelo->Configuracion->Estados->Estados = 'en';
$modelo->save();
If I do this, it returns this error.
Indirect modification of overloaded property Mymodelo::$Configuracion has no effect
and if I do this
$modelo = json_decode(Mymodelo::where('_id,'=',$registro)->first());
$modelo->Configuracion->Estados->Idioma= 'en';
$modelo->save();
Doing this does not update anything in the registry, and ends up throwing me an error that says that the method stdclass :: save (); it is undefined.
The only way I have managed to update a record is by doing it indirectly, but I would like it to be direct.
$modelo = Mymodelo::where('_id,'=',$registro)->first();
$mod = json_decode($modelo->Configuracion->Estados);
$mod->Idioma = "en";
$modelo->Configuracion = $mod;
$modelo->save();
I have not used the methods provided by the Jenssegers library because it does not end up matching the data structure I'm handling.
Really, thank you very much.