The AI suggests me this.
DB::table('rules')
->where('id', 1)
->update([
'options' => DB::raw("JSON_SET(options, '$.visible.enabled', true)"),
]);
But it doesn't work. I get no error, but the options field remains unchanged.
Hello,
I have a question about this documentation.
https://laravel.com/docs/11.x/queries#updating-json-columns
DB::table('users')
->where('id', 1)
->update(['options->enabled' => true]);
But I'd like to update a deeper property in the JSON field.
DB::table('users')
->where('id', 1)
->update(['options->visible->enabled' => true]);
I have tested, it doesn't work ... or perhaps I have to code this differently ?
GIven that the application receives several events from micro-services, I need to avoid read/write collisions, so the only way seems to update the table via a single query.
Thanks for your help.
V
@vincent15000 I would strongly consider not having such json columns, rather have related table data.
Please or to participate in this conversation.