本文整理匯總了PHP中Paginator::getCurrentPage方法的典型用法代碼示例。如果您正苦於以下問題:PHP Paginator::getCurrentPage方法的具體用法?PHP Paginator::getCurrentPage怎麽用?PHP Paginator::getCurrentPage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Paginator
的用法示例。
在下文中一共展示了Paginator::getCurrentPage方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: simpleRendeArray
/**
* create pagination with only previous and next buttons
*
* @return array
*/
public function simpleRendeArray()
{
$array = [];
$count = $this->paginator->getCount();
$url = $this->path;
$current = $this->paginator->getCurrentPage();
// create appends string
$appends = $this->createAppendString($this->paginator->getAppends());
// create fragments string
$fragments = $this->createFragmentsString($this->paginator->getFragments());
if ($count < $this->paginator->getPerPage()) {
$limit = 1;
} else {
$limit = ceil($count / $this->paginator->getPerPage());
}
if ($this->isAvaibleCurrentPage($current) && $current > 1) {
$previous = $current - 1;
$array[] = $this->buildChieldString('Previous', $this->buildFullChieldStrind($url, $appends), $this->pageName, $fragments, $previous);
}
if ($this->isAvaibleCurrentPage($current) && $current < $limit) {
$next = $current + 1;
$array[] = $this->buildChieldString('Next', $this->buildFullChieldStrind($url, $appends), $this->pageName, $fragments, $next);
}
return $array;
}
示例2: getResultPaginate
public function getResultPaginate()
{
if (count($this->results) <= 0) {
$this->getResult();
}
$currentPage = \Paginator::getCurrentPage();
return array_slice($this->results, ($currentPage - 1) * static::$app['config']->get('statistics::paginate_num'), static::$app['config']->get('statistics::paginate_num'));
}
示例3: generar_paginacion_articulos_segun_tag
/**
* Retorna articulos segun tag
* @return object
*/
public function generar_paginacion_articulos_segun_tag()
{
$sEntrada = Input::get('sEntrada');
$oArticuloCaracteristicaValorCategoria = new ArticuloCaracteristicaValorCategoria();
$oElementosPaginacion = $oArticuloCaracteristicaValorCategoria->Obtener_todos_segun_tag($sEntrada);
//dd($oElementosPaginacion);die;
// Get pagination information and slice the results.
$iElementpsPorPagina = 8;
$iTotalElementosPaginacion = count($oElementosPaginacion);
$start = (Paginator::getCurrentPage() - 1) * $iElementpsPorPagina;
$sliced = array_slice($oElementosPaginacion, $start, $iElementpsPorPagina);
// Eager load the relation.
$oColeccion = Articulo::hydrate($sliced);
// Create a paginator instance.
return Paginator::make($oColeccion->all(), $iTotalElementosPaginacion, $iElementpsPorPagina);
}
示例4: testGetData
public function testGetData()
{
var_dump(Paginator::getCurrentPage());
}
示例5: respondWithPagination
/**
* @param Paginator $items
* @param $data
* @return \Illuminate\Http\JsonResponse
*/
protected function respondWithPagination($items, $data)
{
$data = array_merge($data, ['paginator' => ['total_count' => $items->getTotal(), 'total_pages' => ceil($items->getTotal() / $items->getPerPage()), 'current_page' => $items->getCurrentPage(), 'limit' => $items->getPerPage()]]);
return $this->respond($data);
}
示例6: LimitIterator
}
if (!empty($limit)) {
$this->setItemsPerPage($limit);
}
// quickly calculate the offset based on the page
if ($page > 0) {
$page -= 1;
}
$offset = $page * $this->_itemsPerPage;
// return the limit iterator
return new LimitIterator($this->_it, $offset, $this->_itemsPerPage);
}
}
// generate an example of page items to iterate over
$items = array(array('id' => 1, 'name' => 'Item 1', 'desc' => 'Description', 'price' => 4.99), array('id' => 2, 'name' => 'Item 2', 'desc' => 'Description', 'price' => 4.99), array('id' => 3, 'name' => 'Item 3', 'desc' => 'Description', 'price' => 4.99), array('id' => 4, 'name' => 'Item 4', 'desc' => 'Description', 'price' => 4.99), array('id' => 5, 'name' => 'Item 5', 'desc' => 'Description', 'price' => 4.99), array('id' => 6, 'name' => 'Item 6', 'desc' => 'Description', 'price' => 4.99), array('id' => 7, 'name' => 'Item 7', 'desc' => 'Description', 'price' => 4.99), array('id' => 8, 'name' => 'Item 8', 'desc' => 'Description', 'price' => 4.99), array('id' => 9, 'name' => 'Item 9', 'desc' => 'Description', 'price' => 4.99), array('id' => 10, 'name' => 'Item 10', 'desc' => 'Description', 'price' => 4.99), array('id' => 11, 'name' => 'Item 11', 'desc' => 'Description', 'price' => 4.99), array('id' => 12, 'name' => 'Item 12', 'desc' => 'Description', 'price' => 4.99), array('id' => 13, 'name' => 'Item 13', 'desc' => 'Description', 'price' => 4.99), array('id' => 14, 'name' => 'Item 14', 'desc' => 'Description', 'price' => 4.99), array('id' => 15, 'name' => 'Item 15', 'desc' => 'Description', 'price' => 4.99), array('id' => 16, 'name' => 'Item 16', 'desc' => 'Description', 'price' => 4.99), array('id' => 17, 'name' => 'Item 17', 'desc' => 'Description', 'price' => 4.99), array('id' => 18, 'name' => 'Item 18', 'desc' => 'Description', 'price' => 4.99), array('id' => 19, 'name' => 'Item 19', 'desc' => 'Description', 'price' => 4.99), array('id' => 20, 'name' => 'Item 20', 'desc' => 'Description', 'price' => 4.99), array('id' => 21, 'name' => 'Item 21', 'desc' => 'Description', 'price' => 4.99));
// load the paginator
$Paginator = new Paginator(new ArrayIterator($items));
// displays the initial set (page 1, limit 10)
$results = $Paginator->render();
foreach ($results as $r) {
var_dump($r);
}
// check for another page
if ($Paginator->hasNextPage()) {
echo 'DISPLAYING THE NEXT SET OF RESULTS AS AN EXAMPLE' . PHP_EOL;
// displays the next page results as an example
$results = $Paginator->render($Paginator->getCurrentPage() + 1);
foreach ($results as $r) {
var_dump($r);
}
}
示例7: respondWithPagination
/**
* @param Paginator $elements
* @param $data
*
* @return \Illuminate\Http\JsonResponse
*/
public function respondWithPagination(Paginator $elements, $data)
{
$data = array_merge($data, ['paginator' => ['totalCount' => $elements->getTotal(), 'totalPages' => ceil($elements->getTotal() / $elements->getPerPage()), 'currentPage' => $elements->getCurrentPage(), 'limit' => $elements->getPerPage()]]);
return $this->respond($data);
}