本文整理汇总了PHP中Illuminate\Pagination\Paginator::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Paginator::toArray方法的具体用法?PHP Paginator::toArray怎么用?PHP Paginator::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Pagination\Paginator
的用法示例。
在下文中一共展示了Paginator::toArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: transformPaginator
private function transformPaginator(Paginator $paginator)
{
$array = $paginator->toArray();
unset($array['data']);
// Add pagination info
$current_page = $paginator->getCurrentPage();
$next_page = min($current_page + 1, $paginator->getLastPage());
$previous_page = max($current_page - 1, 1);
$array['next_page'] = $next_page === $current_page ? NULL : $paginator->getUrl($next_page);
$array['previous_page'] = $previous_page === $current_page ? NULL : $paginator->getUrl($previous_page);
return $array;
}
示例2: DataGrid
public function DataGrid()
{
$users = $this->userRepository->all();
// dd(get_class($this->groupRepository));
// print_r($users);
// dd($users);
$perPage = 15;
$currentPage = Input::get('page') - 1;
$pagedData = array_slice($users, $currentPage * $perPage, $perPage);
$users = new Paginator($pagedData, $perPage, $currentPage);
// dd($users);
$data['total'] = count($users->toArray());
// dd($users->toArray());
$datagrab = $users->toArray()['data'];
foreach ($users as $key => $user) {
// dd( array_flip( $group->getPermissions()));
$datagrab[$key]['id'] = $user->hash;
$datagrab[$key]['permissions'] = implode(",", array_flip($user->getPermissions()));
}
$data['rows'] = $datagrab;
return json_encode($data);
}