$coordinator = []; $coordinatorFirstPage = Api::schoolTeacher()->index($schoolId, $filter); $coordinator[] = $coordinatorFirstPage->data(); $lastPage = $coordinatorFirstPage->meta('last_page') ?? 1; $promCordinators = Http::pool(function (Pool $pool) use ($lastPage, $schoolId, $filter) { for ($c = 2; $c <= $lastPage; $c++) { $filter['page'] = $c; $pool->withToken(Auth::user()->token()) ->get(Api::schoolTeacher()->index($schoolId, $filter, true), $filter); } }); foreach ($promCordinators as $wraped) { $coordinator[] = json_decode($wraped->getBody(), true)['data'] ?? []; } $coordinator = collect($coordinator)->flatten(1)->toArray(); dd($coordinator);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter