讨论数量:
使用resource
或者
$list = $list->paginate();
foreach ($list->items() as $item) {
$item->key1 = $value1;
$item->key2 = $value2;
}
return $list;
使用 getCollection 拿到集合,再使用 transform 或者 map。
$list = $list->paginate();
$list->getCollection()->transform(function(){
// TODO
})
使用resource
或者
$list = $list->paginate();
foreach ($list->items() as $item) {
$item->key1 = $value1;
$item->key2 = $value2;
}
return $list;