Reputation: 642
Problem is how do i print collection
s into view. and first div only print Collection 0
and next one Collection ++
like this
ExamsController@create
$collections = $questions->split(5);
$collections->toArray();
dd($collections);
dd($collections);
Collection {#455 ▼
#items: array:5 [▼
0 => Collection {#394 ▶}
1 => Collection {#619 ▶}
2 => Collection {#407 ▶}
3 => Collection {#398 ▶}
4 => Collection {#275 ▶}
]
}
Create.blade.php
<div>@foreach($collections as $collection)
Collection 0
@endforeach</div>
<div>@foreach($collections as $collection)
Collection 1
@endforeach</div>
<div>@foreach($collections as $collection)
Collection 2
@endforeach</div>
<div>@foreach($collections as $collection)
Collection 3
@endforeach</div>
<div>@foreach($collections as $collection)
Collection 4
@endforeach</div>
Upvotes: 1
Views: 2190
Reputation: 9853
Use index
to fetch particular collections
@foreach($collections[0] as $collection) //here $collection is Collection 0
Upvotes: 1