php - How to name an array when using map function on a collection in Laravel -
i need build structure collection in laravel. each block should have subarray named $operators_participants , each of these should have 2 fields (operators , role_operator_id)..
this attempt:
$blocks = $dd->participants->map(function ($i, $k) { $operators_participants = $i->operators->map(function ($item, $key) { return [ 'operator' => $item, 'role_operator_id' => $item->pivot->role_operator_id ]; }); return $operators_participants; });
Comments
Post a Comment