count(); return self::paginator($results->forPage($page, $pageSize), $total, $pageSize, $page, [ 'path' => Paginator::resolveCurrentPath(), 'pageName' => 'page', ]); } /** * Create a new length-aware paginator instance. * * @param \Illuminate\Support\Collection $items * @param integer $total * @param integer $perPage * @param integer $currentPage * @param array $options * @return \Illuminate\Pagination\LengthAwarePaginator */ protected static function paginator( Collection $items, int $total, int $perPage, int $currentPage, array $options ): \Illuminate\Pagination\LengthAwarePaginator { return Container::getInstance()->makeWith(LengthAwarePaginator::class, [ 'items' => $items, 'total' => $total, 'perPage' => $perPage, 'currentPage' => $currentPage, 'options' => $options ]); } /** * Get an array of views for each recipe models given. * * @param \Illuminate\Pagination\LengthAwarePaginator $models * @param string $path * @param string $key * @return array */ public static function getViewsFromPaginateModels( LengthAwarePaginator $models, string $path, string $key ): array { return $models->through(function ($model) use ($path, $key) { return view($path, [$key => $model])->render(); })->toArray(); } /** * Get an array of views for each item in collection given. * * @param \Illuminate\Support\Collection $collection * @param string $path * @param string $key * @return array */ public static function getViewsFromCollection(Collection $collection, string $path, string $key): array { return $collection->map(function ($item) use ($path, $key) { return view($path, [$key => $item])->render(); })->toArray(); } }