本文整理汇总了PHP中Illuminate\Pagination\LengthAwarePaginator::count方法的典型用法代码示例。如果您正苦于以下问题:PHP LengthAwarePaginator::count方法的具体用法?PHP LengthAwarePaginator::count怎么用?PHP LengthAwarePaginator::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Pagination\LengthAwarePaginator
的用法示例。
在下文中一共展示了LengthAwarePaginator::count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
/**
* @return mixed
*/
public function search()
{
$query = Input::get('q');
$order_by = null !== Input::get('field') ? Input::get('field') : 'id';
$sort = null !== Input::get('sort') ? Input::get('sort') : 'asc';
$user = $this->users->searchUsers($query, true, $order_by, $sort);
$total = $user->count();
$pageName = 'page';
$per_page = config('access.users.default_per_page');
$page = null;
//Create custom pagination
$users = new LengthAwarePaginator($user, $total, $per_page, $page, ['path' => Paginator::resolveCurrentPath(), 'pageName' => $pageName]);
if ($users->count() == 0) {
return redirect()->route('admin.access.users.index')->withFlashDanger('Your search term "' . $query . '" not found!');
}
return view('backend.access.index', compact('users'))->withRoles($this->roles->getAllRoles('id', 'asc', true));
}
示例2: respondWithPagination
/**
* @param LengthAwarePaginator $paginatorData
* @param $data
*
* @return mixed
*/
public function respondWithPagination(LengthAwarePaginator $paginatorData, $data)
{
$data = array_merge($data, ['paginator' => ['total_count' => $paginatorData->total(), 'total_pages' => ceil($paginatorData->total() / $paginatorData->perPage()), 'current_page' => $paginatorData->currentPage(), 'limit' => $paginatorData->count(), 'next_page_url' => $paginatorData->nextPageUrl()]]);
return $this->respond($data);
}
示例3: checkPagination
/**
* Redirect to page 1 if the paginator is empty.
* @param \Illuminate\Pagination\LengthAwarePaginator $paginator
* @return \Illuminate\Support\Facades\Redirect
*/
protected function checkPagination(LengthAwarePaginator $paginator)
{
if ($paginator->count() == 0 && !is_null(Input::get('page')) && (int) Input::get('page') != 1) {
App::abort(Response::HTTP_TEMPORARY_REDIRECT, '', ['Location' => route(Route::current()->getName(), Input::except('page') + ['page' => 1])]);
}
}
示例4: paginate
public function paginate(LengthAwarePaginator $paginator)
{
return ["count" => $paginator->count(), "current_page" => $paginator->currentPage(), "last_page" => $paginator->lastPage(), "per_page" => $paginator->perPage(), "total" => $paginator->total()];
}
示例5: tableNavStatus
/**
* @param LengthAwarePaginator $paginated_list
* @return string
*/
public function tableNavStatus(LengthAwarePaginator $paginated_list)
{
return trans('global.table_list.results.status', ['start' => $paginated_list->perPage() * ($paginated_list->currentPage() - 1) + 1, 'stop' => $paginated_list->count() + ($paginated_list->currentPage() - 1) * $paginated_list->perPage(), 'total' => $paginated_list->total()]);
}