V5.0.9版本开始 支持分页类后数据直接each遍历处理,方便修改分页后的数据,而不是只能通过模型的获取器来补充字段。
$list = User::where('status',1)->paginate()->each(function($item, $key){ $item->nickname = 'think';});
如果是Db类操作分页数据的话,each方法的闭包函数中需要使用返回值,例如:
$list = Db::name('user')->where('status',1)->paginate()->each(function($item, $key){ $item['nickname'] = 'think'; return $item;});
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!