xxxxxxxxxx
//After Eloquent query you can modify rows by using •map()• function in Collections.
$users = User::where('role_id', 1)->get()->map(function (User $user) {
$user->some_column = some_function($user);
return $user;
});
xxxxxxxxxx
// dont copy this
$all_items = $this->excel->oldest('excel_data.id')->get();
$resource = collect()->range(0, 178)->map(function ($value) use ($all_items) {
$instance = $all_items[$value] ?? null;
return [
'main_rows' => $instance?->main_rows ?? null,
];
});