cakephp 4 cannot find a finder method

53 Views Asked by At

I had a finder method called "findActive" in my CarsTable.php , I call it from another controller: VehiclesController.php :

CarsTable.php

    public function findActive(Query $query, array $options): Query
       { ..... }

// Controller VehiclesController.php

 $carsTable = TableRegistry::getTableLocator()->get('cars');
 $activeCars = $carsTable->find('active');

Before I migrated it to cake 4 it was working fine. Any clue?

1

There are 1 best solutions below

0
wowDAS On

Try the following

  • Write you Model in CamelCase: TableRegistry::getTableLocator()->get('cars') -> TableRegistry::getTableLocator()->get('Cars')
  • Check if the namespace, .php file extension and location of the file is correct.
  • Check if your query in findActive is correct (which I assume is the case) - the signature looks fine