本文整理汇总了PHP中Illuminate\Pagination\LengthAwarePaginator::render方法的典型用法代码示例。如果您正苦于以下问题:PHP LengthAwarePaginator::render方法的具体用法?PHP LengthAwarePaginator::render怎么用?PHP LengthAwarePaginator::render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Pagination\LengthAwarePaginator
的用法示例。
在下文中一共展示了LengthAwarePaginator::render方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeLengthAware
/**
* Create paginator
*
* @param Illuminate\Support\Collection $collection
* @param int $total
* @param int $perPage
* @return string
*/
public static function makeLengthAware($collection, $total, $perPage)
{
$paginator = new LengthAwarePaginator($collection, $total, $perPage, Paginator::resolveCurrentPage(), ['path' => Paginator::resolveCurrentPath()]);
return str_replace('/?', '?', $paginator->render());
}
示例2: paginate
/**
* paginate to create my table
*
*
* @param $table
* @param $table_name
* @return string
*/
protected function paginate($table, $table_name)
{
$paginate = new LengthAwarePaginator($table, count($table), $this->row_per_page, $this->current_page);
$total_rows = count($table);
// we should select only posts that we want;
$table = array_slice($table, $this->current_page * $this->row_per_page - $this->row_per_page, $this->row_per_page);
$start_id = $this->current_page * $this->row_per_page - $this->row_per_page;
$start_id++;
$end_id = $this->current_page * $this->row_per_page;
if ($end_id > $total_rows) {
$end_id = $total_rows;
}
if ($total_rows == 0) {
$start_id = 0;
}
if ($end_id < $this->row_per_page) {
$this->row_per_page = $end_id;
}
$footer_info = "<div style='margin-top:17px;float:left;' class='footer-data-table-info'>نمایش <b>" . $start_id . "</b> تا <b>" . $end_id . "</b> ، <b>" . $this->row_per_page . "</b> سطر در هر صفحه ، کل سطرها <b>{$total_rows}</b></div>";
return json_encode([$table_name => $table, "paginate" => $paginate->render(), "page_id" => $this->current_page, "row_per_page" => $this->row_per_page, "start_id" => $start_id, "footer_info" => $footer_info, "random" => $this->random_number]);
}
示例3: render
public function render($class = null)
{
return $this->paginator->render(static::$defaultView);
}
示例4: respondWithPaginated
public function respondWithPaginated(LengthAwarePaginator $paginated, $status = 200)
{
$this->options['paginationCode'] = $paginated->render();
$this->prepareEloquentResult($paginated);
return $this->respond(collect($paginated), $status);
}