Open atrauzzi opened 5 years ago
There already is a collection
cast, but this doesn't solve the mutation issue. See #1275.
@atrauzzi, if I understand your problem correctly, the changes proposed in laravel/framework#30958 will make it easy to solve.
Love being able to have DB JSON types cast to arrays using the
'json'
$casts
property.One thing I noticed was that because arrays are always copied (rather than referenced), you end up with verbose code when you want to mutate the value:
This got me thinking that it would be great if there was something like a
json_collection
cast that returned an instance wrapped bycollect()
.Benefits:
Love it? Hate it? It was just a thought I had this morning... 😄