Answer the question
In order to leave comments, you need to log in
How to update json?
The model has param and value(json) fields. {'value': {'total': 100, 'current': 10} }
I need to increase the current value.
So I do it like this:
$taxation = Taxation::where('param', 'BALANCE')->first()->value;
$current = $taxation['current']; // текущее значение
$taxation['value->current'] = $current + $someValue;
$taxation->save();
System::where('param', 'BALANCE')->update([
'value->current' => 3 // вот тут получается добавить только "статичные данные", то есть не получится узнать текущее значение и прибавить к нему что то
'value->current' => DB::raw('value->current + 3') // работать не будет
]);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question