[laravel的分页操作]laravel的分页操作 #laravel
$skinRecordColls=$user->userSkinRecords();
$paginator = $skinRecordColls->whereBetween('created_at',[$star_time,$end_time])
->latest('created_at')
->paginate($perPage);
foreach($paginator->items() as $item)
{
$item_detail;
switch($item->record_type)
{
case "skinrun":
$item_detail=SkinRunRecords::where('id',$item->record_id)->first();
$detecor=$this->skinRunDetector;
break;
}
$data[]=$detecor->analysisDetectResult($item, $item_detail, $language);
}
$respone = new \stdClass();
$respone->current_page=$paginator->currentPage();
$respone->last_page=$paginator->lastPage();
$respone->data=$data;
$respone->total=$paginator->total();
具体操作详见laravel的文档:https://laravel.com/docs/5.8/pagination#paginator-instance-methods