當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Collection::forPage方法代碼示例

本文整理匯總了PHP中Illuminate\Support\Collection::forPage方法的典型用法代碼示例。如果您正苦於以下問題:PHP Collection::forPage方法的具體用法?PHP Collection::forPage怎麽用?PHP Collection::forPage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Support\Collection的用法示例。


在下文中一共展示了Collection::forPage方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: paginate

 /**
  * Paginate the results of this query
  *
  * @param  int
  * @param  int
  * @return $this
  */
 public function paginate($perPage, $page)
 {
     if ($perPage > 0) {
         $this->collection = $this->collection->forPage($page, $perPage);
     }
     return $this;
 }
開發者ID:lykegenes,項目名稱:laravel-api-response,代碼行數:14,代碼來源:EloquentCollectionStrategy.php

示例2: addIssue

 /**
  * @param FunctionalTester\UserSteps $I
  *
  * @actor FunctionalTester\UserSteps
  *
  * @return void
  */
 public function addIssue(FunctionalTester\UserSteps $I)
 {
     $I->am('Admin User');
     $I->wantTo('add new issue to a project');
     $admin = $I->createUser(1, 4);
     $developer1 = $I->createUser(2, 2);
     // developer
     $I->login($admin->email, '123', $admin->firstname);
     $project = $I->createProject(1, [$developer1]);
     $I->sendAjaxGetRequest($I->getApplication()->url->action('Administration\\TagsController@getTags', ['term' => 'f']));
     $tags = new Collection((array) $I->getJsonResponseContent());
     $I->amOnAction('Project\\IssueController@getNew', ['project' => $project]);
     $I->seeOptionIsSelected('assigned_to', $developer1->fullname);
     $params = ['title' => 'issue 1', 'body' => 'body of issue 1', 'tag' => $tags->forPage(0, 2)->implode('value', ','), 'assigned_to' => $developer1->id, 'time_quote' => ['h' => 1, 'm' => 2, 's' => 3]];
     $I->submitForm('#content .form-horizontal', $params);
     $issue = $I->fetchIssueBy('title', $params['title']);
     $I->seeCurrentActionIs('Project\\IssueController@getIndex', ['project' => $project, 'issue' => $issue]);
     $I->seeResponseCodeIs(200);
     $I->seeLink($params['title']);
     $I->see($params['body'], '.content');
     $I->see(\Html::duration($issue->time_quote), '.issue-quote');
     foreach ($tags->forPage(0, 2) as $tag) {
         $segments = explode(':', $tag->label);
         $I->see($segments[0], '.issue-tag');
         $I->see($segments[1], '.issue-tag');
     }
 }
開發者ID:oliverpool,項目名稱:tinyissue,代碼行數:34,代碼來源:CrudIssueCest.php

示例3: createIssues

 /**
  * @param \FunctionalTester\UserSteps $I
  *
  * @actor FunctionalTester\UserSteps
  *
  * @return void
  */
 public function createIssues(FunctionalTester\UserSteps $I)
 {
     $I->am('Manager User');
     $I->expectTo('create issues in all projects');
     $user = $I->createUser(1, 3);
     $project1 = $I->createProject(1);
     $project2 = $I->createProject(2, [$user]);
     $I->login($user->email, '123', $user->firstname);
     $I->sendAjaxGetRequest($I->getApplication()->url->action('Administration\\TagsController@getTags', ['term' => 'f']));
     $tags = new Collection((array) $I->getJsonResponseContent());
     $params = ['title' => 'issue 1', 'body' => 'body of issue 1', 'tag' => $tags->forPage(0, 1)->implode('value', ','), 'time_quote' => ['h' => 1, 'm' => 1, 's' => 1]];
     $I->amOnAction('Project\\IssueController@getNew', ['project' => $project2]);
     $I->seeResponseCodeIs(200);
     $I->submitForm('#content .form-horizontal', $params);
     $issue = $I->fetchIssueBy('title', $params['title']);
     $I->seeCurrentActionIs('Project\\IssueController@getIndex', ['project' => $project2, 'issue' => $issue]);
     $I->seeResponseCodeIs(200);
     $I->seeLink($params['title']);
     $I->amOnAction('Project\\IssueController@getNew', ['project' => $project1]);
     $I->seeResponseCodeIs(200);
 }
開發者ID:oliverpool,項目名稱:tinyissue,代碼行數:28,代碼來源:PermissionManagerCest.php

示例4: testPaginate

 public function testPaginate()
 {
     $c = new Collection(['one', 'two', 'three', 'four']);
     $this->assertEquals(['one', 'two'], $c->forPage(1, 2)->all());
     $this->assertEquals([2 => 'three', 3 => 'four'], $c->forPage(2, 2)->all());
     $this->assertEquals([], $c->forPage(3, 2)->all());
 }
開發者ID:sa7bi,項目名稱:euro16,代碼行數:7,代碼來源:SupportCollectionTest.php


注:本文中的Illuminate\Support\Collection::forPage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。