# Custom Finder Methods error in cakephp 3

**URL:** https://discourse.cakephp.org/t/custom-finder-methods-error-in-cakephp-3/3186
**Category:** Need Help
**Created:** [September 14, 2017, 6:54am UTC](https://discourse.cakephp.org/t/custom-finder-methods-error-in-cakephp-3/3186 "2017-09-14T06:54:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![luchinilato](https://avatars.discourse-cdn.com/v4/letter/l/6a8cbe/32.png) [@luchinilato](https://discourse.cakephp.org/u/luchinilato)
#### Post date: [September 14, 2017, 6:54am UTC](https://discourse.cakephp.org/t/custom-finder-methods-error-in-cakephp-3/3186/1 "2017-09-14T06:54:30Z")

</div>

I have a Custom Finder Method in the model and trying to call it in the controller it is not found.

follows the code in the model VehiclesTable.php:

```
 public function listarVeiculosDisponiveis(Query $query, array $options)
    {
        return $query->where(['empresa_id' => 1]);
    }

```

in the file OrcamentosController.php I have the following method:

```
public function add()
{
    $orcamento = $this->Orcamentos->newEntity();
    if ($this->request->is('post')) {
        $orcamento = $this->Orcamentos->patchEntity($orcamento, $this->request->data);
        $orcamento['empresa_id'] = $this->Auth->user('empresa_id');
        $orcamento['user_id'] = $this->Auth->user('id');

        if ($this->Orcamentos->save($orcamento)) {
            $this->Flash->success(__('O orçamento foi salvo com sucesso.'));

            return $this->redirect(['action' => 'index']);
        } else {
            $this->Flash->error(__('Erro ao salvar orçamento, tente novamente.'));
        }
    }

    $clientes = $this->Orcamentos->Clientes->find('list', ['conditions' => ['empresa_id' => $this->Auth->user('empresa_id'), 'excluido' => 0], 'fields' => ['id', 'nome'] ]);

    $veiculos = TableRegistry::get('Veiculos');
    $veiculos_disponiveis = $veiculos->find('listarVeiculosDisponiveis');

    $users = $this->Orcamentos->Users->find('list', ['limit' => 200]);
    $this->set(compact('orcamento', 'clientes', 'users', 'veiculos_disponiveis'));
    $this->set('_serialize', ['orcamento']);
}

```

when running I get the following error: **Unknown finder method “listarVeiculosDisponiveis”**

Where can I be wrong? I did as you say in the documentation

---

<div class="post-metadata">

### Author: ![deanoj](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@deanoj](https://discourse.cakephp.org/u/deanoj)
#### Post date: [September 14, 2017, 11:01am UTC](https://discourse.cakephp.org/t/custom-finder-methods-error-in-cakephp-3/3186/2 "2017-09-14T11:01:30Z")

</div>

Make sure the proper model is loaded, otherwise Cake will default to auto tables and not find your method at all.

Also looks like your model name doesn’t follow expected convention. Example:

Model method:

public function findSomething(Query $query, array $options)

Controller:

$this-\>loadModel(‘Things’);  
$this-\>Things-\>find(‘something’);

---

<div class="post-metadata">

### Author: ![rrd](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/rrd/32/113_2.png) [@rrd](https://discourse.cakephp.org/u/rrd)
#### Post date: [September 14, 2017, 3:06pm UTC](https://discourse.cakephp.org/t/custom-finder-methods-error-in-cakephp-3/3186/3 "2017-09-14T15:06:36Z")

</div>

You shoudl rename your method to `findListarVeiculosDisponiveis`. All custom finder method name should start with `find`.
