问题是如何将收藏夹打印到视图中.并且第一个div仅打印Collection 0,而下一个Collection这样打印
ExamsController @创建
$collections = $questions->split(5);
$collections->toArray();
dd($collections);
DD($集合);
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)
收藏0
@endforeach</div>
<div>@foreach($collections as $collection)
集合1
@endforeach</div>
<div>@foreach($collections as $collection)
集合2
@endforeach</div>
<div>@foreach($collections as $collection)
集合3
@endforeach</div>
<div>@foreach($collections as $collection)
集合4
@endforeach</div>
解决方法:
使用索引获取特定集合
@foreach($collections[0] as $collection) //here $collection is Collection 0
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。