/** * Create a new paginator instance. * * @param mixed $items * @param int $perPage * @param int|null $currentPage * @param array $options (path, query, fragment, pageName) * @return void */ public function __construct($items, $perPage, $currentPage = null, array $options = []) { foreach ($options as $key => $value) { $this->{$key} = $value; } $this->perPage = $perPage; $this->currentPage = $this->setCurrentPage($currentPage); $this->path = $this->path != '/' ? rtrim($this->path, '/') : $this->path; $this->items = $items instanceof Collection ? $items : Collection::make($items); $this->checkForMorePages(); }
/** * Sort the array using the given callback. * * @param array $array * @param callable $callback * @return array */ public static function sort($array, callable $callback) { return Collection::make($array)->sortBy($callback)->all(); }