Good Day I have this code on backend (trying to update this value in MONGO) http://prntscr.com/j03gh4
$dossier=Dossier::where('_id',(int)$request->input('dossier_id'))->first();
//var_dump($request->input('value'));
$dossier->program[$request->input('program')]['cities']
[$request->input('city')]['services']
[$request->input('service')][$request->input('name')]=$request->input('value');
$dossier->save();
But I receive this Exception http://prntscr.com/j03h0s
Indirect modification of overloaded property App\Dossier::$program has no effect
What have I do to repair this situation?
The problem is that calling $dossier->program
does not actually access the property directly in Eloquent type models but rather calls a __get
method.
That get method does not return a reference to the property. What you should do is grab the original property, modify it and then put it back:
$dossier=Dossier::where('_id',(int)$request->input('dossier_id'))->first();
$originalProgram = $dossier->program;
$originalProgram[$request->input('program')]['cities'][$request->input('city')]['services'][$request->input('service')][$request->input('name')]=$request->input('value');
$dossier->program = $originalProgram;
$dossier->save();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With