Q:

Laravel Array & JSON casting

I am using this to insert data in JSON format into table. What I would like to know is if it is possible to change one property of JSON object after it is inserted into table with more then one properties. For example:
Table:
+----+----------------------------------+
| id |               car                |
+----+----------------------------------+
|  1 | {"brand": "audi", "model": "TT"} |
+----+----------------------------------+

$entity = Table::where('id', 1);
$entity->car['model'] = 'Aicon';

Code, similar to this, gives me an exception 'ErrorException' with message 'Indirect modification of overloaded property ... has no effect' in ....

A:

Such as in the Doc’s example you cannot, you have to take the JSON object (as an array), change it, and then put it back.
$entity = Table::where('id', 1);
$car = $entity->car;
$car['model'] = 'Aicon';
$entity->car = $car;
$entity->save();

