examples/AdWords/LaravelSampleApp/app/Http/Controllers/AdWordsApiController.php
private function fetchCampaigns(
        Request $request,
        CampaignService $campaignService,
        array $selectedFields,
        $entriesPerPage,
        $pageNo
    ) {
        $query = (new ServiceQueryBuilder())
            ->select($selectedFields)
            ->orderByAsc('Name')
            ->limit(
                ($pageNo - 1) * $entriesPerPage,
                intval($entriesPerPage)
            )->build();

        $totalNumEntries = 0;
        $results = [];

        $page = $campaignService->query("$query");
        if (!empty($page->getEntries())) {
            $totalNumEntries = $page->getTotalNumEntries();
            $results = $page->getEntries();
        }

        $request->session()->put('totalNumEntries', $totalNumEntries);

        return collect($results);
    }
private function fetchCampaigns(
        Request $request,
        CampaignService $campaignService,
        array $selectedFields,
        $entriesPerPage,
        $pageNo
    ) {
        $query = (new ServiceQueryBuilder())
            ->select($selectedFields)
            ->orderByAsc('Name')
            ->limit(
                ($pageNo - 1) * $entriesPerPage,
                intval($entriesPerPage)
            )->build();

        $totalNumEntries = 0;
        $results = [];

        $page = $campaignService->query("$query");
        if (!empty($page->getEntries())) {
            $totalNumEntries = $page->getTotalNumEntries();
            $results = $page->getEntries();
        }

        $request->session()->put('totalNumEntries', $totalNumEntries);

        return collect($results);
    }
private function fetchCampaigns ( Request $ request , CampaignService $ campaignService , array $ selectedFields , $ entriesPerPage , $ pageNo ) { $ query = ( new ServiceQueryBuilder ( ) ) -> select ( $ selectedFields ) -> orderByAsc ( 'Name' ) -> limit ( ( $ pageNo - 1 ) * $ entriesPerPage , intval ( $ entriesPerPage ) ) -> build ( ) ; $ totalNumEntries = 0 ; $ results = [ ] ; $ page = $ campaignService -> query ( "$query" ) ; if ( ! empty ( $ page -> getEntries ( ) ) ) { $ totalNumEntries = $ page -> getTotalNumEntries ( ) ; $ results = $ page -> getEntries ( ) ; } $ request -> session ( ) -> put ( 'totalNumEntries' , $ totalNumEntries ) ; return collect ( $ results ) ; }
Fetch campaigns using the provided campaign service, selected fields, the
number of entries per page and the specified page number.

@param Request $request
@param CampaignService $campaignService
@param string[] $selectedFields
@param int $entriesPerPage
@param int $pageNo
@return Collection
Fetch campaigns using the provided campaign service selected fields the number of entries per page and the specified page number .