当前位置: 首页>>代码示例>>PHP>>正文


PHP Paginator::resolveCurrentPath方法代码示例

本文整理汇总了PHP中Illuminate\Pagination\Paginator::resolveCurrentPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Paginator::resolveCurrentPath方法的具体用法?PHP Paginator::resolveCurrentPath怎么用?PHP Paginator::resolveCurrentPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Pagination\Paginator的用法示例。


在下文中一共展示了Paginator::resolveCurrentPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(Request $request)
 {
     $letter = $request->input('letter');
     if (!isset($letter) || !$letter) {
         $projects = $this->projectsGateway->findFeaturedProjects();
         Debugbar::info($projects);
         $data = array('letter' => strtoupper($letter), 'projects' => $projects);
         return view('projects', $data);
     }
     $projects = $this->projectsGateway->findProjectsByLetter($letter);
     $paginator = new LengthAwarePaginator($projects['data'], $projects['total'], $projects['per_page'], Paginator::resolveCurrentPage(), ['path' => Paginator::resolveCurrentPath()]);
     Debugbar::info($projects);
     $data = array('letter' => strtoupper($letter), 'projects' => $projects['data'], 'paginator' => $paginator);
     return view('projects_by_letter', $data);
 }
开发者ID:kleopatra999,项目名称:cjan.org,代码行数:20,代码来源:ProjectsController.php

示例2: response

 /**
  * @param $results
  * @param $with
  * @param $paginated
  * @param Searchable|null $model
  * @return array|LengthAwarePaginator
  */
 protected function response($results, $with, $paginated, Searchable $model = null)
 {
     $collection = $this->asModels($results['hits']['hits'], $model);
     /*
      * if we also want to lazy load relations, we'll create a collection and load them,
      * pass them on to the paginator if needed
      * heads up: i believe nested documents will always be loaded,
      * so developer should only pass with relations that aren't being indexed by Elasticsearch
      */
     if ($with) {
         $model->unguard();
         $collection = $model->newCollection($collection);
         $model->reguard();
         $collection->load($with);
     }
     if ($paginated) {
         /*
          * if we lazy loaded some relations, we need to get back an array to paginate.
          * not an optimal way of doing this, but i believe there isn't a better way at this point,
          * since the paginator only takes an array.
          */
         $collection = is_array($collection) ? $collection : $collection->all();
         $path = Paginator::resolveCurrentPath();
         //for some reason things do not work when passing in the options as an regular array
         $results = new LengthAwarePaginator($collection, $results['hits']['total'], $paginated);
         $results->setPath($path);
         //only need transform into a collection when we didn't lazyload relations
     } elseif (is_array($collection)) {
         $results = $model->newCollection($collection);
     } else {
         $results = $collection;
     }
     return $results;
 }
开发者ID:jaffle-be,项目名称:framework,代码行数:41,代码来源:SearchResponder.php

示例3: paginate

 /**
  * Return the paginated dataset of the underlying database.
  *
  * @param int    $perPage
  * @param array  $columns
  * @param string $pageName
  * @param int    $page
  *
  * @return \Illuminate\Pagination\Paginator
  */
 public function paginate($perPage, $columns, $pageName, $page)
 {
     $total = count($this->db);
     $page = $page ?: Paginator::resolveCurrentPage($pageName);
     $results = array_slice($this->get(), ($page - 1) * $perPage, $perPage);
     return new LengthAwarePaginator($results, $total, $perPage, $page, ['path' => Paginator::resolveCurrentPath(), 'pageName' => $pageName]);
 }
开发者ID:tjbp,项目名称:tablelegs,代码行数:17,代码来源:NumericArray.php

示例4: AllContents

 /**
  * 取得未删除的信息
  *
  * @return array
  * @todo 数据量多时,查找属于指定分类,推荐位,标签三个的文章时使用redis集合交集处理,避免查询消耗。
  */
 public function AllContents($search = [])
 {
     $prefix = \DB::getTablePrefix();
     $currentQuery = $this->select(['article_main.*', 'users.name'])->leftJoin('users', 'article_main.user_id', '=', 'users.id')->leftJoin('article_classify_relation', 'article_main.id', '=', 'article_classify_relation.article_id')->leftJoin('article_classify', 'article_classify_relation.classify_id', '=', 'article_classify.id')->leftJoin('article_position_relation', 'article_main.id', '=', 'article_position_relation.article_id')->leftJoin('article_tag_relation', 'article_main.id', '=', 'article_tag_relation.article_id')->orderBy('article_main.id', 'desc')->where('article_main.is_delete', self::IS_DELETE_NO)->groupBy('article_main.id')->distinct();
     if (isset($search['keyword']) && !empty($search['keyword'])) {
         $currentQuery->where('article_main.title', 'like', "%{$search['keyword']}%");
     }
     if (isset($search['username']) && !empty($search['username'])) {
         $currentQuery->where('article_main.user_id', $search['username']);
     }
     if (isset($search['classify']) && !empty($search['classify'])) {
         $currentQuery->where('article_classify_relation.classify_id', $search['classify']);
     }
     if (isset($search['position']) && !empty($search['position'])) {
         $currentQuery->where('article_position_relation.position_id', $search['position']);
     }
     if (isset($search['tag']) && !empty($search['tag'])) {
         $currentQuery->where('article_tag_relation.tag_id', $search['tag']);
     }
     if (isset($search['timeFrom'], $search['timeTo']) and !empty($search['timeFrom']) and !empty($search['timeTo'])) {
         $search['timeFrom'] = strtotime($search['timeFrom']);
         $search['timeTo'] = strtotime($search['timeTo']);
         $currentQuery->whereBetween('article_main.write_time', [$search['timeFrom'], $search['timeTo']]);
     }
     $total = count($currentQuery->get()->all());
     $currentQuery->forPage($page = Paginator::resolveCurrentPage(), $perPage = self::PAGE_NUMS);
     $result = $currentQuery->get()->all();
     return new LengthAwarePaginator($result, $total, $perPage, $page, ['path' => Paginator::resolveCurrentPath()]);
 }
开发者ID:mikegit2014,项目名称:laravelback,代码行数:35,代码来源:Content.php

示例5: paginate

 public function paginate($perPage = 15, $columns = ['*'], $pageName = 'page', $page = null)
 {
     $page = $page ?: Paginator::resolveCurrentPage($pageName);
     $total = $this->count();
     $results = $this->forPage($page, $perPage);
     return new LengthAwarePaginator($results, $total, $perPage, $page, ['path' => Paginator::resolveCurrentPath(), 'pageName' => $pageName]);
 }
开发者ID:recca0120,项目名称:laravel-support,代码行数:7,代码来源:Collection.php

示例6: index

 /**
  * Ce controller à pour but de gérer la logique de recherche d'un film dans la base de données
  * Le controller gère aussi les topics lorsque l'utilisateur fait une recherche via les checkboxes sur
  * la page de d'affichage des résultats.
  * Les fonctions paginate servent à créer le paginator qui est simplement l'affichage des films 20 par 20.
  *
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $search = Input::get('search');
     $topics = Input::except('search', 'page');
     if (empty($topics)) {
         // Pas de topics on renvoie simplement les films correspondants
         $allMovies = Movies::where('title', 'like', "%{$search}%")->paginate(20)->appends(Input::except('page'));
     } else {
         // SI on a des topics dans l'input il est nécessaire de filtrer
         $movies = Topics::whereIn('topic_name', $topics)->with('movies')->get();
         $moviesCollection = Collection::make();
         foreach ($movies as $movy) {
             $moviesCollection->add($movy->movies()->where('title', 'like', "%{$search}%")->get());
         }
         $moviesCollection = $moviesCollection->collapse();
         // Il n'est pas possible de créer la paginator directement, on le crée donc à la main
         $page = Input::get('page', 1);
         $perPage = 20;
         $offset = $page * $perPage - $perPage;
         $allMovies = new LengthAwarePaginator($moviesCollection->slice($offset, $perPage, true), $moviesCollection->count(), $perPage);
         $allMovies->setPath(Paginator::resolveCurrentPath());
         $allMovies->appends(Input::except('page'));
     }
     // A la vue correspondante on lui renvoie une liste des films correspondants à la recherche, le tout paginé
     return view('search', compact('allMovies'));
 }
开发者ID:Tirke,项目名称:ShortMovies,代码行数:35,代码来源:SearchController.php

示例7: getPaginatedEntries

 /**
  * Returns the entries for the current page for this view.
  *
  * @return \Illuminate\Pagination\LengthAwarePaginator paginator containing the entries for the page, sorted/ordered or not.
  */
 public function getPaginatedEntries()
 {
     // Gets all the entries, sensitive to whether we're sorting for this request.
     $allEntries = $this->getEntriesSortable();
     $page = Paginator::resolveCurrentPage('page');
     // Returns the number of entries perpage, defined by Model#getPerPage
     $perPage = $allEntries->first()->getPerPage();
     // If the page number is beyond the number of pages, get it back to the last page.
     while (($page - 1) * $perPage > count($allEntries)) {
         $page -= 1;
     }
     // Return the subset of the entries for this page
     $entriesForPage = $allEntries->splice(($page - 1) * $perPage, $perPage);
     // Return the paginator for this subset.
     $entriesPaginator = new LengthAwarePaginator($entriesForPage, $this->getEntries()->first()->toBase()->getCountForPagination(), $perPage, $page, ['path' => Paginator::resolveCurrentPath(), 'pageName' => 'page']);
     // If we're ordering, append that to the links
     if ($this->getSortOrder()) {
         $entriesPaginator->appends(['order' => Request::get('order')]);
     }
     // If we're sorting, append that to the links
     if ($this->isSorting()) {
         $entriesPaginator->appends(['sort' => $this->getSortKey()]);
     }
     return $entriesPaginator;
 }
开发者ID:uidaho,项目名称:squireproject,代码行数:30,代码来源:PaginatedRequest.php

示例8: paginateCollection

 /**
  * Paginates a collection. For simple pagination, one can override this function
  *
  * a little help from http://laravelsnippets.com/snippets/custom-data-pagination
  *
  * @param Collection $data
  * @param int $perPage
  * @param Request $request
  * @param null $page
  *
  * @return LengthAwarePaginator
  */
 public function paginateCollection(Collection $data, $perPage, Request $request, $page = null)
 {
     $pg = $request->get('page');
     $page = $page ? (int) $page * 1 : (isset($pg) ? (int) $request->get('page') * 1 : 1);
     $offset = $page * $perPage - $perPage;
     return new LengthAwarePaginator($data->splice($offset, $perPage), $data->count(), $perPage, Paginator::resolveCurrentPage(), ['path' => Paginator::resolveCurrentPath()]);
 }
开发者ID:muhamadsyahril,项目名称:ecommerce-1,代码行数:19,代码来源:EloquentExtensions.php

示例9: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($projectId, $versionId, $id, Request $request)
 {
     $w = $request->input('w', self::ASC);
     if (!$w || strcmp("", trim($w)) === 0 || !in_array(trim($w), [self::ASC, self::DESC]) || strcmp(sprintf("%d", self::DESC), trim($w)) === 0) {
         $w = self::ASC;
     } else {
         $w = self::DESC;
     }
     //$o = $request->input('o', /* only option*/ 3);
     $o = 3;
     $version = $this->versionsGateway->findById($versionId);
     $project = $version['project_artifact'];
     Debugbar::info($version);
     // $testRuns = $this->testRunsGateway->findByVersionId($version['id']);
     // Debugbar::info($testRuns);
     $testRun = $this->testRunsGateway->findById($id, $o, $w);
     Debugbar::info($testRun);
     $tests = $testRun['tests'];
     Debugbar::info($tests);
     $paginator = new LengthAwarePaginator($tests['data'], $tests['total'], $tests['per_page'], Paginator::resolveCurrentPage(), ['path' => Paginator::resolveCurrentPath(), 'query' => ["o" => $o, "w" => $w]]);
     Debugbar::info($paginator);
     $letter = strtoupper($project['name'][0]);
     $user = $testRun['user'];
     $data = array('projectId' => $projectId, 'versionId' => $versionId, 'version' => $version, 'project' => $project, 'id' => $id, 'testRun' => $testRun, 'letter' => $letter, 'user' => $user, 'tests' => $tests['data'], 'paginator' => $paginator, 'w' => $w);
     return view('test_run', $data);
 }
开发者ID:kleopatra999,项目名称:cjan.org,代码行数:32,代码来源:TestRunsController.php

示例10: paginate

 /**
  * Paginates the Elasticsearch results.
  *
  * @param int $perPage
  * @return mixed
  */
 public function paginate($perPage = 15)
 {
     $page = Paginator::resolveCurrentPage('page');
     $paginator = new LengthAwarePaginator($this->items, $this->total(), $perPage, $page);
     $start = ($paginator->currentPage() - 1) * $perPage;
     $sliced = array_slice($this->items, $start, $perPage);
     return new LengthAwarePaginator($sliced, $this->total(), $perPage, $page, ['path' => Paginator::resolveCurrentPath(), 'pageName' => 'page']);
 }
开发者ID:mozzos,项目名称:bouncy,代码行数:14,代码来源:ElasticCollection.php

示例11: index

 public function index()
 {
     $level = Input::get('levels', 'all');
     $levels = array('all' => 'ALL', 'debug' => 'DEBUG', 'info' => 'INFO', 'notice' => 'NOTICE', 'warning' => 'WARNING', 'error' => 'ERROR', 'critical' => 'CRITICAL', 'alert' => 'ALERT', 'emergency' => 'EMERGENCY');
     $logs = LogViewer::getLogs($level);
     $paginator = new LengthAwarePaginator($logs, count($logs), 25, ['path' => Paginator::resolveCurrentPath()]);
     return view('backend.log.index', compact('paginator', 'levels', 'level'));
 }
开发者ID:MehmetNuri,项目名称:fullycms,代码行数:8,代码来源:LogController.php

示例12: createPaginator

 /**
  * create aLengthAwarePaginator from an Eloquent Request
  * This is useful because Laravel 5 only provide a simple paginator
  * out of the box.
  *
  * @param $builder
  * @param $perPage
  * @return LengthAwarePaginator
  */
 function createPaginator($builder, $perPage)
 {
     $page = Paginator::resolveCurrentPage();
     $builder->skip(($page - 1) * $perPage)->take($perPage + 1);
     $queryClone = clone $builder->getQuery();
     $total = $queryClone->skip(0)->take($perPage + 1)->count();
     return new LengthAwarePaginator($builder->get(), $total, $perPage, $page, ['path' => Paginator::resolveCurrentPath()]);
 }
开发者ID:oimken,项目名称:sharp,代码行数:17,代码来源:SharpEloquentLengthAwarePaginatorCreatorTrait.php

示例13: paginate

 /**
  * Create paginator
  *
  * @param  array  $items
  * @param  int    $perPage
  * @return LengthAwarePaginator
  */
 public function paginate($items, $perPage)
 {
     $pageStart = \Request::get('page', 1);
     // Start displaying items from this number;
     $offSet = $pageStart * $perPage - $perPage;
     // Get only the items you need using array_slice
     $itemsForCurrentPage = array_slice($items, $offSet, $perPage, true);
     return new LengthAwarePaginator($itemsForCurrentPage, count($items), $perPage, Paginator::resolveCurrentPage(), array('path' => Paginator::resolveCurrentPath()));
 }
开发者ID:aerojun,项目名称:pcmrcritic,代码行数:16,代码来源:ArrayPaginator.php

示例14: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $page = Input::get('page', 1);
     $perPage = 10;
     $pagiData = $this->news->paginate($page, $perPage, true);
     $news = new LengthAwarePaginator($pagiData->items, $pagiData->totalItems, $perPage, ['path' => Paginator::resolveCurrentPath()]);
     $news->setPath("");
     return view('backend.news.index', compact('news'));
 }
开发者ID:RudolfFussek,项目名称:fullycms,代码行数:14,代码来源:NewsController.php

示例15: index

 /**
  * Display videos page
  * @param $id
  * @return \Illuminate\View\View
  */
 public function index()
 {
     //$videos = $this->video->paginate();
     $page = Input::get('page', 1);
     $perPage = 12;
     $pagiData = $this->video->paginate($page, $perPage, false);
     $videos = new LengthAwarePaginator($pagiData->items, $pagiData->totalItems, $perPage, ['path' => Paginator::resolveCurrentPath()]);
     $videos->setPath("");
     return view('frontend.video.index', compact('videos'));
 }
开发者ID:phillipmadsen,项目名称:deved,代码行数:15,代码来源:VideoController.php


注:本文中的Illuminate\Pagination\Paginator::resolveCurrentPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。