Promise Multi

PHOTO EMBED

Fri Jul 22 2022 03:40:39 GMT+0000 (Coordinated Universal Time)

Saved by @GodFather #php #laravel

$promises = Http::pool(function (Pool $pool) use ($schoolId, $filter, $batch, $studentGroupId) {
            $pool->as('schoolStaff')->withToken(Auth::user()->token())
                ->get(Api::schoolStaff()->index($schoolId, [], true), $filter);
            $pool->as('schoolBatchStudentGroup')->withToken(Auth::user()->token())
                ->get(Api::schoolBatchStudentGroup()->detail($schoolId, $batch, $studentGroupId, true));
        });

        $staffDatas = json_decode($promises['schoolStaff']->getBody(), true)['data'] ?? [];
        $studentGroup = json_decode($promises['schoolBatchStudentGroup']->getBody(), true)['data'] ?? [];
content_copyCOPY