Welcome Guest, Not a member yet? Register   Sign In
Tutorial for creating custom Bootstrap 4 pagers and page numbers
#11

(04-19-2023, 01:45 AM)remesses_thegreat Wrote:
(04-18-2023, 11:00 PM)InsiteFX Wrote: You need to use grouping.

CodeIgniter 4 User Guide - Library Reference Pagination - Paginating Multiple Results

I'm really sorry to bother you. Never done this and its going over my head. Not sure what I'm doing wrong. So i tried it with the first two groups it worked fine. The moment i added other group it only returns one page of each. Here is my code maybe I'm doing it wrong. I have a lot of data being rendered onto just one page. I know it maybe stupid but honestly dont know what i need to change 

PHP Code:
$data = [
                'pendingapproval' => $companiesmodel->where('status''pending')->paginate(5,'group1'),
                'verifiedcompanies' => $companiesmodel->where('status''Approved')->paginate(5,'group2'),
                'activepayments' => $companiesmodel->where('paymentstatus''active')->paginate(5,'group3'),
                'inactivepayments' => $companiesmodel->where('paymentstatus''inactive')->paginate(10,'group4'),
                'apicompanies' => $companiesmodel->where('role''apicompany')->paginate(10,'group5'),

                'appusers' => $appusers->paginate(10,'group6'),
                'contractors' => $dmodel->paginate(10,'group7'),
                'users' => $cumodel->where('role''companyuser')->paginate(10,'group8'),
                'pending' => $coldelmodel->where('cstatus''pending')->paginate(10,'group9'),
                'completed' => $coldelmodel->where('cstatus''completed')->paginate(10,'group10'),
                'requests' => $srmodel->where('sstatus''pending')->paginate(10,'group11'),
              
                
'currentPage' => $companiesmodel->pager->getCurrentPage('group1'), // The current page number
                'totalPages'  => $companiesmodel->pager->getPageCount('group1'),
                'vcurrentPage' => $companiesmodel->pager->getCurrentPage('group2'), // The current page number
                'vtotalPages'  => $companiesmodel->pager->getPageCount('group2'),    // The total page count

                'activecurrentPage' => $companiesmodel->pager->getCurrentPage('group3'), // The current page number
                'activetotalPages'  => $companiesmodel->pager->getPageCount('group3'),    // The total page count

                'inactivecurrentPage' => $companiesmodel->pager->getCurrentPage('group4'), // The current page number
                'inactivetotalPages'  => $companiesmodel->pager->getPageCount('group4'),    // The total page count

                'apicurrentPage' => $companiesmodel->pager->getCurrentPage('group5'), // The current page number
                'apitotalPages'  => $companiesmodel->pager->getPageCount('group5'),    // The total page count

                'appcurrentPage' => $appusers->pager->getCurrentPage('group6'), // The current page number
                'apptotalPages'  => $appusers->pager->getPageCount('group6'),    // The total page count

                'concurrentPage' => $dmodel->pager->getCurrentPage('group7'), // The current page number
                'contotalPages'  => $dmodel->pager->getPageCount('group7'),    // The total page count

                'userscurrentPage' => $cumodel->pager->getCurrentPage('group8'), // The current page number
                'userstotalPages'  => $cumodel->pager->getPageCount('group8'),    // The total page count

                'pendcurrentPage' => $coldelmodel->pager->getCurrentPage('group9'), // The current page number
                'pendtotalPages'  => $coldelmodel->pager->getPageCount('group9'),    // The total page count

                'comcurrentPage' => $coldelmodel->pager->getCurrentPage('group10'), // The current page number
                'comtotalPages'  => $coldelmodel->pager->getPageCount('group10'),    // The total page count

                'reqcurrentPage' => $srmodel->pager->getCurrentPage('group11'), // The current page number
                'reqtotalPages'  => $srmodel->pager->getPageCount('group11'),    // The total page count
                'pager' => $companiesmodel->pager,
                'apppager' => $appusers->pager,
                'conpager' => $dmodel->pager,
                'userpager' => $cumodel->pager,
                'colpager' => $coldelmodel->pager,
                'reqpager' => $srmodel->pager,
            ]; 

Solution in my case was to create multiple data array calls to modal. With each pager following its respective model call. Example below 

PHP Code:
            $companiesmodel = new CompaniesModel();
            $dmodel = new ContractorssModel();
            $cumodel = new CompanyUserModel();
            $coldelmodel = new ColDelModel();
            $smodel = new ServicesModel();
            $pmodel = new ProductsModel();
            $emodel = new EventsModel();
            $srmodel = new ServiceRequestModel();
            $appusers = new UsersModel();
            $filesmodel = new BusinessFilesModel();
            $companyID session()->get('id');

            $data['pendingapproval'] = $companiesmodel->where('status''pending')->paginate(5,'group1');
            $data['pager'] = $companiesmodel->pager;
            $data['verifiedcompanies'] = $companiesmodel->where('status''Approved')->paginate(5,'group2');
            $data['vpager'] = $companiesmodel->pager;
            $data['activepayments'] = $companiesmodel->where('paymentstatus''active')->paginate(10,'group3');
            $data['apager'] = $companiesmodel->pager;
            $data['inactivepayments'] = $companiesmodel->where('paymentstatus''inactive')->paginate(10,'group4');
            $data['inactivepager'] = $companiesmodel->pager;
            $data['apicompanies'] = $companiesmodel->where('role''apicompany')->paginate(10,'group5');
            $data['apipager'] = $companiesmodel->pager;
  
          
      
        
            $data
['appusers'] = $appusers->paginate(10,'group6');
            $data['apppager' ]= $appusers->pager;

            $data['contractors'] = $dmodel->paginate(10,'group7');
            $data['conpager'] = $dmodel->pager;
            $data['users'] = $cumodel->where('role''companyuser')->paginate(10,'group8');
            $data['userpager'] = $cumodel->pager;
            $data['pending'] = $coldelmodel->where('cstatus''pending')->paginate(10,'group9');
            $data['pendcolpager'] = $coldelmodel->pager;
            $data['completed'] = $coldelmodel->where('cstatus''completed')->paginate(10,'group10');
            $data['comcolpager'] = $coldelmodel->pager;
            $data['requests'] = $srmodel->where('sstatus''pending')->paginate(10,'group11');
            $data['reqpager'] = $srmodel->pager;
      

              
                $data
['currentPage'] = $companiesmodel->pager->getCurrentPage('group1'); // The current page number
                $data['totalPages']  $companiesmodel->pager->getPageCount('group1');
                $data['vcurrentPage'] = $companiesmodel->pager->getCurrentPage('group2'); // The current page number
                $data['vtotalPages']  $companiesmodel->pager->getPageCount('group2');    // The total page count

                $data['activecurrentPage'] = $companiesmodel->pager->getCurrentPage('group3'); // The current page number
                $data['activetotalPages']  $companiesmodel->pager->getPageCount('group3');    // The total page count

                $data['inactivecurrentPage'] = $companiesmodel->pager->getCurrentPage('group4'); // The current page number
                $data['inactivetotalPages']  $companiesmodel->pager->getPageCount('group4');    // The total page count

                $data['apicurrentPage'] = $companiesmodel->pager->getCurrentPage('group5'); // The current page number
                $data['apitotalPages']  $companiesmodel->pager->getPageCount('group5');    // The total page count

                $data['appcurrentPage'] = $appusers->pager->getCurrentPage('group6'); // The current page number
                $data['apptotalPages']  $appusers->pager->getPageCount('group6');    // The total page count

                $data['concurrentPage'] = $dmodel->pager->getCurrentPage('group7'); // The current page number
                $data['contotalPages']  $dmodel->pager->getPageCount('group7');    // The total page count

                $data['userscurrentPage']  $cumodel->pager->getCurrentPage('group8'); // The current page number
                $data['userstotalPages']  $cumodel->pager->getPageCount('group8');    // The total page count

                $data['pendcurrentPage'] = $coldelmodel->pager->getCurrentPage('group9'); // The current page number
                $data['pendtotalPages']  $coldelmodel->pager->getPageCount('group9');    // The total page count

                $data['comcurrentPage'] = $coldelmodel->pager->getCurrentPage('group10'); // The current page number
                $data['comtotalPages' ] = $coldelmodel->pager->getPageCount('group10');    // The total page count

                $data['reqcurrentPage'] = $srmodel->pager->getCurrentPage('group11'); // The current page number
                $data['reqtotalPages']  $srmodel->pager->getPageCount('group11');    // The total page count
                
Reply
#12

Are you adding the group names to the links in your views?
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#13

(04-25-2023, 10:14 PM)InsiteFX Wrote: Are you adding the group names to the links in your views?

Yes thank you work as expected. Appreciated
Reply




Theme © iAndrew 2016 - Forum software by © MyBB