Hi guys, i am trying to get a massive amounts of records while looping through an array. Right now the way data is collecting is
Collection {#2209 ▼
#items: array:150 [▼
0 => Collection {#2405 ▼
#items: array:150 [▼
0 => {#2403 …6}
1 => {#2400 …6}
2 => {#2397 …6}
3 => {#2399 …6}
4 => {#2402 …6}
5 => {#2398 …6}
6 => {#2401 …6}
7 => {#2395 …6}
8 => {#2394 …6}
9 => {#2393 …6}
10 => {#2392 …6}
11 => {#2391 …6}
12 => {#2390 …6}
13 => {#2389 …6}
...
i want the child collection to be emitted so instead of 146 items above it will be 300 and no child collections. This is the way my code is right now.
$schools = collect();
foreach($lgas as $lga){
$school = DB::table('schools')
->join('school_categories', 'schools.school_category_id', '=', 'school_categories.id')
->leftJoin('school_sub_categories', 'school_sub_categories.id', '=', 'schools.school_sub_category_id')
->join('addresses', 'addresses.id', '=', 'schools.address_id')
->select('schools.name',
'schools.code',
'school_categories.name as category_name',
'school_sub_categories.name as sub_category_name',
'schools.email',
'schools.phone')
->where('addresses.lga_id', $lga)
->get();
$schools->push($school);
}
Is there any possible way that i can achieve that? Thanks in advance