for eg:-
foreach ($data as $key => $value) {
$new_data[$value->attribute_id]['options'][$value->id] = $value->name;
}
Indirect modification of overloaded element of App\Attribute has no effect gives me this error.
although i solve it by using this code but i still need to understand if I can modify collection like directly pointing towards key like we do in array even if it is a model object in it.
return collect($new_data)->transform(function ($value) use ($data){
$value->options = $data->reduce(function ($newattr_value,$attr_value) use($value) {
if($attr_value['attribute_id'] == $value->id){
$newattr_value[$attr_value['id']] = $attr_value['name'];
}
return $newattr_value;
},[]);
return $value;
});
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3dmaDqv
via IFTTT
Aucun commentaire:
Enregistrer un commentaire