openclassify/addons/default/visiosoft/advs-module/src/Adv/AdvCollection.php

30 lines
946 B
PHP

<?php namespace Visiosoft\AdvsModule\Adv;
use Anomaly\Streams\Platform\Entry\EntryCollection;
use Illuminate\Container\Container;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;
class AdvCollection extends EntryCollection
{
public function paginate($pageSize = null)
{
$pageSize = $pageSize ?: setting_value('streams::per_page');
$page = Paginator::resolveCurrentPage('page');
$total = $this->count();
return self::paginator($this->forPage($page, $pageSize), $total, $pageSize, $page, [
'path' => Paginator::resolveCurrentPath(),
'pageName' => 'page',
]);
}
protected static function paginator($items, $total, $perPage, $currentPage, $options)
{
return Container::getInstance()->makeWith(LengthAwarePaginator::class, compact(
'items', 'total', 'perPage', 'currentPage', 'options'
));
}
}