Controller Code:
public $paginate = [
'fields' => ['Subscribes.id'],
'limit' => 1,
'order' => [
'Subscribes.created' => 'desc'
]
];
Controller Method Code: Here $type is variable, value can be interger 1,2 3 etc
$customFinderOptions = [
'type' => $type
];
$this->paginate = [
'finder' => [
'typed' => $customFinderOptions
]
];
$contacts = $this->paginate($this->Subscribes);
Model Code:
public function findTyped(Query $query, array $options) {
$type = $options['type'];
return $query->where(['type' => $options['type']]);
}
Error: As you can see limit is set to 1 but it returns all the records. Which means pagination is not working with custom finder method.