code: public function paginate($perPage = 15, $pageName = 'page')
      {
          $page = Paginator::resolveCurrentPage($pageName);
          $total = $this->count();
          $results = $this->forPage($page, $perPage)->getList();
  
          return new LengthAwarePaginator($results, $total, $perPage, $page, [
              'path' => Paginator::resolveCurrentPath(),
              'pageName' => $pageName,
          ]);
      }
docs: Paginate the given query into a paginator.
  
  @param  int  $perPage
  @param  string  $pageName
  
  @return \Illuminate\Pagination\LengthAwarePaginator