分页工作时不使用for循环,当想要使用for或foreach循环对数据进行结构化时,分页正在隐藏响应。这是我的代码。当我用于循环或foreach循环时,分页对象正在隐藏。
$calls = DB::table('call')
->where('call.company_id', '=', $company_id)
->orderBy('call.created_at', 'ASC')
->paginate($perPage, array( $columns ), 'current_page', $currentPage);
$lead = new Lead();
$i = 0;
for($i=0; $i < count($calls); ++$i){
$callData = "";
$callData['id'] = $calls[$i]->id;
$callData['date'] = $calls[$i]->date;
$callData['duration'] = $calls[$i]->duration;
$callData['user_id'] = $calls[$i]->user_id;
$callData['contact_number'] = $calls[$i]->contact_number;
$callData['from_time'] = $calls[$i]->from_time;
$callData['call_type'] = $calls[$i]->call_type;
$callData['created_by'] = $calls[$i]->created_by;
$callData['created_at'] = $calls[$i]->created_at;
$callData['updated_at'] = $calls[$i]->updated_at;
$callsData[] = $callData;
}
return $callsData;