CMS Tutorial findBySlug not found


#1

In the CMS tutorial the has a call to findBySlug like the following in the ArticlesController.php file:

    public function view($slug)
{
    $article = $this->Articles->findBySlug($slug)->firstOrFail();
    $this->set(compact('article'));
}

My ide, PhpStorm, highlights the function and says it is not found in “\App\Model\Table\ArticlesTable”.
What am I missing?


#2

you dont miss anything its called using magic __call function

you can hint your IDE by adding docBlock before table class declaration:

/**
 * @method \Cake\ORM\Query findBySlug(string $slug)
 */

#3

Thanks Graziel, that worked.