Welcome Guest, Not a member yet? Register   Sign In
Pagination Problems
#12

Just for the record if you have already solved it.
In Ci4 that's the use of the callbacks in models. And what you need here isĀ afterFind
So in the model you put something like...
PHP Code:
protected $afterFind = ['filterResults']; 

Then you create the method in the same model

PHP Code:
protected function filterResults($eventData)
    {
/*
$eventData = ['method', 'limit', 'offset', 'data', 'singleton']
*/

        
switch ($eventData['method']) {
            case 
'findAll':
                foreach (
$eventData['data'] as $row) {

//modify the result here in case of findAll
                    
$rows[] = $row;
                }

                return [
'data' => $rows];

                break;
            case 
'find':

                
$row $eventData['data'];

  
// modify the result here in case of find
                
return ['data' => $row];

                break;
            } 

With that the paginate still work.
Reply


Messages In This Thread
Pagination Problems - by Gary - 09-29-2020, 11:36 AM
RE: Pagination Problems - by InsiteFX - 09-29-2020, 03:56 PM
RE: Pagination Problems - by nc03061981 - 09-29-2020, 05:33 PM
RE: Pagination Problems - by InsiteFX - 09-29-2020, 05:36 PM
RE: Pagination Problems - by nc03061981 - 09-29-2020, 05:40 PM
RE: Pagination Problems - by Gary - 09-30-2020, 04:24 AM
RE: Pagination Problems - by nc03061981 - 09-30-2020, 06:13 PM
RE: Pagination Problems - by Gary - 10-01-2020, 04:01 PM
RE: Pagination Problems - by InsiteFX - 10-01-2020, 04:53 PM
RE: Pagination Problems - by nc03061981 - 10-01-2020, 05:40 PM
RE: Pagination Problems - by Gary - 10-02-2020, 02:45 AM
RE: Pagination Problems - by heriniaina - 06-12-2022, 08:44 AM
RE: Pagination Problems - by Gary - 06-23-2022, 09:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB