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


PHP LengthAwarePaginator::appends方法代码示例

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


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

示例1: 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

示例2: 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

示例3: make

 /**
  * Return table pagination data.
  *
  * @param Table $table
  * @return array
  */
 public function make(Table $table)
 {
     $options = $table->getOptions();
     $perPage = $options->get('limit') ?: config('streams::system.per_page');
     $pageName = $table->getOption('prefix') . 'page';
     $page = app('request')->get($pageName);
     $path = '/' . app('request')->path();
     $paginator = new LengthAwarePaginator($table->getEntries(), $options->get('total_results', 0), $perPage, $page, compact('path', 'pageName'));
     $pagination = $paginator->toArray();
     $pagination['links'] = $paginator->appends(app('request')->all())->render();
     return $pagination;
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:18,代码来源:TablePagination.php

示例4: search

 /**
  * Полнотекстовый поиск с разбивкой на страницы
  * @param $request
  * @return LengthAwarePaginator
  */
 public static function search($request)
 {
     $results = [];
     $search = $request->input('q');
     $path = Paginator::resolveCurrentPath();
     $page = Paginator::resolveCurrentPage('page');
     $per_page = config('paginator.per_page');
     $offset = ((int) $page - 1) * $per_page;
     $sql = 'SELECT SQL_CALC_FOUND_ROWS A.*, MATCH(A.name, A.text) AGAINST (?) AS score
             FROM articles AS A
             WHERE MATCH(A.name, A.text) AGAINST (?)
             ORDER BY score DESC, A.name ASC LIMIT ? OFFSET ?';
     $articles_ids = DB::select($sql, [$search, $search, $per_page, $offset]);
     $total = DB::select('SELECT FOUND_ROWS() AS total')[0]->total;
     foreach ($articles_ids as $item) {
         $results[] = Article::find($item->id);
     }
     $paginator = new LengthAwarePaginator($results, $total, $per_page, $page, ['path' => $path]);
     $paginator->appends('q', $search);
     return $paginator;
 }
开发者ID:oiljin,项目名称:newsportal,代码行数:26,代码来源:Article.php

示例5: paginateSearchedProducts

 /**
  * Paginate searched products.
  *
  * @param string $searchTerm
  * @param int $page
  * @return LengthAwarePaginator
  */
 protected static function paginateSearchedProducts($searchTerm, $page)
 {
     // Query for results
     $results = \DB::table('application_products')->where('code', 'like', "{$searchTerm}%")->orWhere('name', 'like', "{$searchTerm}%")->orderBy('created_at', 'desc')->get();
     // Make sure page is always positive
     if ($page < 1) {
         $page = 1;
     }
     $perPage = Settings::displayedBills();
     // Calculate start from
     $startFrom = $perPage * ($page - 1);
     $sliced = array_slice($results, $startFrom, $perPage);
     $paginate = new LengthAwarePaginator($sliced, count($results), $perPage);
     if (isset($searchTerm) && strlen($searchTerm) > 0) {
         $paginate->setPath('/admin-center/products-manager/get/search');
         $paginate->appends(['term' => $searchTerm]);
     } else {
         $paginate->setPath('/admin-center/products-manager/get');
     }
     return $paginate;
 }
开发者ID:bitller,项目名称:nova,代码行数:28,代码来源:ProtectedHelpers.php

示例6: build

 public function build()
 {
     $request = $this->request;
     $needle = $request->needle();
     if ($needle && $request->searchable) {
         $this->qb->where(function ($subQB) use($needle, $request) {
             foreach ($request->searchable as $column) {
                 $subQB->orWhere($column, 'LIKE', "%{$needle}%");
             }
         });
     }
     $request->modifyQuery($this->qb);
     $this->qb->orderBy($request->orderBy(), $request->sortBy());
     $count = $this->qb->count();
     $this->qb->take($request->perPage());
     $this->qb->offset($request->offset());
     $paginator = new LengthAwarePaginator($request->items($this->qb), $count, $request->perPage(), $request->page());
     $paginator->request = $request;
     $paginator->appends($request->query());
     $this->paginator = $paginator;
 }
开发者ID:ohiocms,项目名称:core,代码行数:21,代码来源:BaseLengthAwarePaginator.php

示例7: paginate

 /**
  * Perform query and return pagination results.
  *
  * @param string $searchTerm
  * @param int $page
  * @return LengthAwarePaginator
  */
 protected static function paginate($searchTerm, $page)
 {
     // Query database to get results
     $results = DB::table('products')->where('code', 'like', "{$searchTerm}%")->orWhere('name', 'like', "{$searchTerm}%")->orderBy('code', 'asc')->get();
     // Make sure page is always positive
     self::validatePage($searchTerm);
     $perPage = Settings::displayedBills();
     // Calculate start from
     $startFrom = self::getStartFrom($page, $perPage);
     // Slice the results
     $sliced = self::getSlicedResults($results, $startFrom, $perPage);
     // Initialize the paginator
     $paginate = new LengthAwarePaginator($sliced, count($results), $perPage);
     // Check if search term should be appended to the search path
     if (isset($searchTerm) && strlen($searchTerm) > 0) {
         $paginate->setPath('/my-products/get/search');
         $paginate->appends(['term' => $searchTerm]);
     } else {
         $paginate->setPath('/my-products/get');
     }
     return $paginate;
 }
开发者ID:bitller,项目名称:nova,代码行数:29,代码来源:PaginateProductsSearchResults.php

示例8: Paginator

    $useLengthAware = true;
    // Paginator class example
    if (!$useLengthAware) {
        $paginatorItems = array_slice($items, $offset);
        $results = new Paginator($paginatorItems, $perPage, $currentPage, $options);
    }
    // End of Paginator example
    // LengthAwarePaginator class example
    if ($useLengthAware) {
        $lengthAwarePaginatorItems = array_slice($items, $offset, $perPage);
        $results = new LengthAwarePaginator($lengthAwarePaginatorItems, $total, $perPage, $currentPage, $options);
    }
    // End of LengthAwarePaginator example
    // Display a paginated table of our array
    echo '<h1>I love hashes</h1>';
    echo '<table>';
    foreach ($results as $result) {
        echo "\n        <tr>\n            <td>{$result['id']}</td>\n            <td>{$result['hash']}</td>\n        </tr>";
    }
    echo '<table>' . "\n";
    echo $results->appends($_GET)->render();
    echo 'Current Page: ' . $results->currentPage();
    echo '<br>Items Per Page: ' . $results->perPage();
    // The following methods are only available when using the LengthAwarePaginator instance
    if ($useLengthAware) {
        echo '<br>From ' . $results->firstItem() . ' to ' . $results->lastItem();
        echo '<br>Total Items: ' . $results->total();
        echo '<br>Last Page: ' . $results->lastPage();
    }
});
$app->run();
开发者ID:anteriovieira,项目名称:Torch,代码行数:31,代码来源:index.php

示例9: boardListSearch

 protected function boardListSearch($perPage = 25)
 {
     $input = $this->boardListInput();
     $title = $input['title'];
     $lang = $input['lang'];
     $page = $input['page'];
     $tags = $input['tags'];
     $sfw = $input['sfw'];
     $boards = Board::getBoardsForBoardlist();
     $boards = $boards->filter(function ($item) use($lang, $tags, $sfw, $title) {
         // Are we able to view unindexed boards?
         if (!$item->is_indexed && !$this->user->canViewUnindexedBoards()) {
             return false;
         }
         // Are we requesting SFW only?
         if ($sfw && !$item->is_worksafe) {
             return false;
         }
         // Are we searching by language?
         if ($lang) {
             $boardLang = $item->settings->where('option_name', 'boardLanguage')->pluck('option_value')->first();
             if ($lang != $boardLang) {
                 return false;
             }
         }
         // Are we searching tags?
         if ($tags && count(array_intersect($tags, $item->tags->pluck('tag')->toArray())) < count($tags)) {
             return false;
         }
         // Are we searching titles and descriptions?
         if ($title && stripos($item->board_uri, $title) === false && stripos($item->title, $title) === false && stripos($item->description, $title) === false) {
             return false;
         }
         return true;
     });
     if ($title) {
         $boards = $boards->sort(function ($a, $b) use($title) {
             // Sort by active users, then last post time.
             $aw = 0;
             $bw = 0;
             if ($a->board_uri === $title) {
                 $aw += 8;
             }
             if (stripos($a->board_uri, $title) !== false) {
                 $aw += 4;
             }
             if (stripos($a->title, $title) !== false) {
                 $aw += 2;
             }
             if (stripos($a->description, $title) !== false) {
                 $aw += 1;
             }
             if ($b->board_uri === $title) {
                 $bw += 8;
             }
             if (stripos($b->board_uri, $title) !== false) {
                 $bw += 4;
             }
             if (stripos($b->title, $title) !== false) {
                 $bw += 2;
             }
             if (stripos($b->description, $title) !== false) {
                 $bw += 1;
             }
             return $bw - $aw;
         });
     }
     $paginator = new LengthAwarePaginator($boards->forPage($page, $perPage), $boards->count(), $perPage, $page);
     $paginator->setPath("boards.html");
     foreach ($input as $inputIndex => $inputValue) {
         if ($inputIndex == "sfw") {
             $inputIndex = (int) (!!$inputValue);
         }
         $paginator->appends($inputIndex, $inputValue);
     }
     return $paginator;
 }
开发者ID:JEWSbreaking8chan,项目名称:infinity-next,代码行数:77,代码来源:BoardlistController.php

示例10: _getPaginatorPresenter

 /**
  * Returns Paginator Presenter object if pagination is enabled
  *
  * @param array $items
  * @return mixed
  */
 private function _getPaginatorPresenter(array $items)
 {
     if (!$this->_paginate) {
         return null;
     }
     $params = Input::get();
     if (!empty($params)) {
         // There are parameters in the URL - pass them to paginator
         if (isset($params['page'])) {
             // We don't need that - paginator will add new one
             unset($params['page']);
         }
     }
     // Prepare paginator and pass it to presenter
     $paginator = new LengthAwarePaginator($items, $this->_totalItems, $this->_perPage, $this->_page, ['path' => Request::url()]);
     $paginator->appends($params);
     return new $this->_paginationPresenter($paginator);
 }
开发者ID:msieprawski,项目名称:resource-table,代码行数:24,代码来源:Collection.php

示例11: paginate

 /**
  * Paginator decorator .
  *
  * @param null $perPage
  * @param array $appends
  * @return mixed
  * @throws TableException
  */
 public function paginate($perPage = null, array $appends = array())
 {
     $perPage = isset($perPage) ? $perPage : $this->getPerPage();
     $data = $this->getDriver()->getData($perPage);
     $rows = $data['rows'];
     $total = $data['total'];
     $paginator = new LengthAwarePaginator($rows, $total, $perPage);
     $paginator->setPath(Paginator::resolveCurrentPath());
     $paginator->appends($appends);
     return $paginator;
 }
开发者ID:parfumix,项目名称:table-manager,代码行数:19,代码来源:Table.php

示例12: issueEdit

 public function issueEdit(Request $request)
 {
     $projects = $this->redmine->getProjects()->lists('name', 'id')->toArray();
     $users = $this->redmine->getUsers()->lists('mail', 'id')->toArray();
     $track = $this->redmine->getTrack()->lists('name', 'id')->toArray();
     $status = $this->redmine->getStatus()->lists('name', 'id')->toArray();
     $queries = $this->redmine->getQueries()->lists('name', 'id')->toArray();
     $activity = $this->redmine->getActivity()->lists('name', 'id')->toArray();
     $priority = $this->redmine->getPriority()->lists('name', 'id')->toArray();
     $per_pages = ['25' => '25', '50' => '50', '100' => '100', '200' => '200', '300' => '300'];
     $offset = ($request->input('page', 1) - 1) * $request->input('per_page', 25);
     $parmas['offset'] = $offset;
     $parmas['limit'] = $request->input('per_page', 25);
     if ($request->input('project_id')) {
         $parmas['project_id'] = $request->input('project_id');
     }
     if ($request->input('assigned_to_id')) {
         $parmas['assigned_to_id'] = $request->input('assigned_to_id');
     }
     if ($request->input('status_id')) {
         $parmas['status_id'] = $request->input('status_id');
     }
     if ($request->input('tracker_id')) {
         $parmas['tracker_id'] = $request->input('tracker_id');
     }
     if ($request->input('query_id')) {
         $parmas['query_id'] = $request->input('query_id');
     }
     $issues = $this->client->issue->all($parmas);
     if ($request->input('with_spent_hours')) {
         foreach ($issues['issues'] as $key => $issue) {
             $issues['issues'][$key]['timeentries'] = $this->client->time_entry->all(['limit' => 50, 'issue_id' => $issue['id']]);
             $issues['issues'][$key]['spent_time'] = 0;
             if (!empty($issues['issues'][$key]['timeentries']['time_entries'])) {
                 foreach ($issues['issues'][$key]['timeentries']['time_entries'] as $entry_key => $time_entry) {
                     $issues['issues'][$key]['spent_time'] = $issues['issues'][$key]['spent_time'] + $time_entry['hours'];
                 }
             }
         }
     }
     $pagination = new LengthAwarePaginator($issues['issues'], $issues['total_count'], $parmas['limit'], $request->input('page'));
     $pagination->setPath('/redmine/issues-edit');
     $paglinks = $pagination->appends($request->except(['page']))->render();
     return view('redmine.issues-edit', compact('issues', 'users', 'paglinks', 'projects', 'users', 'track', 'per_pages', 'status', 'queries', 'activity', 'priority'));
 }
开发者ID:karanjilka,项目名称:readmine-api-php-interface,代码行数:45,代码来源:RedmineIssueController.php

示例13: acceptance

 public function acceptance(Request $req)
 {
     $perPage = 20;
     $currPage = $req->input('page', 1);
     $search = ['s' => $req->has('s') ? $req->input('s') : null, 'field' => $req->has('field') ? $req->input('field') : null];
     $data = ['title' => 'Daftar Penerimaan Material', 'asset' => new Assets(), 'js' => ['vendor/jquery.dataTables.min'], 'css' => ['jquery.dataTables'], 'position' => ['material' => 'Material', 'material/acceptance' => 'Penerimaan'], 'fetch' => Pener::fetchData(['search' => $search, 'perPage' => $perPage, 'currPage' => $currPage]), 'opened' => 'material', 'role' => $this->_user->hak_akses, 'active' => 'default', 'search' => $search, 'getNumb' => function () use($perPage, $req) {
         if ($req->has('page') && $req->input('page') != 1) {
             return $req->input('page') * $perPage - $perPage;
         } else {
             return 0;
         }
     }, 'isSelected' => function ($field) use($search) {
         if (!is_null($search['field'])) {
             if ($search['field'] == $field) {
                 return 'selected="selected"';
             }
         }
     }];
     $paginator = new LengthAwarePaginator([], $data['fetch']['total'], $perPage, $currPage);
     $paginator->setPath('acceptance');
     if ($req->has('s')) {
         $paginator->appends(['field' => $search['field'], 's' => $search['s']]);
     }
     $data['paginator'] = $paginator;
     return view('material.baseAcceptance', $data)->nest('dataListContent', 'material.acceptance.index', $data);
 }
开发者ID:aldiunanto,项目名称:gbb_laravel,代码行数:26,代码来源:Material.php

示例14: paginateCollection

 /**
  * @param $collection
  * @param $perPage
  * @return LengthAwarePaginator
  */
 protected function paginateCollection($collection, $perPage)
 {
     $paginator = new LengthAwarePaginator($collection->forPage(Paginator::resolveCurrentPage(), $perPage), $collection->count(), $perPage, Paginator::resolveCurrentPage(), ['path' => Paginator::resolveCurrentPath()]);
     $paginator->appends($this->getQueryParameters());
     return $paginator;
 }
开发者ID:awatbayazidi,项目名称:Transmit,代码行数:11,代码来源:Controller.php

示例15: performBillsPaginationQuery

 protected static function performBillsPaginationQuery($config, $questionMarks, $billIds)
 {
     // Build query
     $query = "SELECT SUM(bills.final_price) AS final_price, SUM(bills.quantity) AS number_of_products, bills.id, bills.client_name, bills.campaign_order, bills.campaign_year, bills.campaign_number, bills.payment_term, bills.created_at FROM ";
     $query .= "(SELECT bill_products.final_price AS final_price, bill_products.quantity, bills.id, clients.name AS client_name, bills.campaign_order, ";
     $query .= "campaigns.year AS campaign_year, campaigns.number AS campaign_number, bills.payment_term, bills.created_at ";
     $query .= "FROM bills LEFT JOIN bill_products ON bill_products.bill_id = bills.id ";
     // Join campaigns
     $query .= "LEFT JOIN campaigns ON bills.campaign_id = campaigns.id ";
     // Join clients table
     $query .= "LEFT JOIN clients ON clients.id = bills.client_id WHERE bills.id IN ({$questionMarks}) ";
     $query .= "UNION ALL SELECT bill_application_products.final_price as final_price, bill_application_products.quantity as quantity, bills.id, ";
     $query .= "clients.name as client_name, bills.campaign_order, campaigns.year as campaign_year, campaigns.number as campaign_number, bills.payment_term, bills.created_at FROM bills ";
     // Join bill application products table
     $query .= "LEFT JOIN bill_application_products ON bill_application_products.bill_id = bills.id ";
     // Join campaigns table
     $query .= "LEFT JOIN campaigns ON campaigns.id = bills.campaign_id ";
     // Join clients table
     $query .= "LEFT JOIN clients ON clients.id = bills.client_id ";
     $query .= "WHERE bills.id IN ({$questionMarks}) AND clients.name=bills.id) bills ";
     $query .= "GROUP BY bills.id ORDER BY bills.created_at DESC";
     // Execute query
     $results = DB::select($query, $billIds);
     // Make sure page is always positive
     if ($config['page'] < 1) {
         $config['page'] = 1;
     }
     $perPage = Settings::displayedBills();
     // Calculate start from
     $startFrom = $perPage * ($config['page'] - 1);
     $sliced = array_slice($results, $startFrom, $perPage);
     $paginate = new LengthAwarePaginator($sliced, count($results), $perPage);
     if (isset($config['searchTerm']) && strlen($config['searchTerm']) > 0) {
         $paginate->setPath('/bills/get/search');
         $paginate->appends(['term' => $config['searchTerm']]);
     } else {
         $paginate->setPath('/bills/get');
     }
     return $paginate;
 }
开发者ID:bitller,项目名称:nova,代码行数:40,代码来源:ProtectedHelpers.php


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