public function paginate($items, $perPage = null, $pageName = 'page', $page = null)
    {
        if (is_array($items)) {
            $items = collect($items);
        }

        $page = $page ?: Paginator::resolveCurrentPage($pageName);

        $perPage = $perPage ?: $items[0]->getPerPage();

        $results = $items->forPage(Paginator::resolveCurrentPage(), $perPage);

        $total = $items->count();

        return new LengthAwarePaginator($results, $total, $perPage, $page, [
            'path'     => Paginator::resolveCurrentPath(),
            'pageName' => $pageName,
        ]);
    }