CodeIgniter Forums
How add autocomplete to $model in Resource Controller - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: How add autocomplete to $model in Resource Controller (/showthread.php?tid=86736)



How add autocomplete to $model in Resource Controller - evilgazz - 02-14-2023

I created class

PHP Code:
class WebWalker extends ResourceController
{
    protected $modelName 'App\Models\WebWalkerModel';
    protected $format 'json';

    public function index() {
        return $this->respond($this->model->findAll());
    }


But phpstorm/vscode don't suggest $this->model->.....

if I add the $model property and add a description to it in PHPDoc, then the autocomplete starts working, Am I doing the right thing?

PHP Code:
class WebWalker extends ResourceController
{
    /**
    * @var WebWalkerModel
    */
    protected $model 'App\Models\WebWalkerModel';
    protected $modelName 'App\Models\WebWalkerModel';
    protected $format 'json';

    public function index() {
        return $this->respond($this->model->findAll());
    }




RE: How add autocomplete to $model in Resource Controller - InsiteFX - 02-15-2023

Yes your doing it right. Until they add these features that's the way it has to be done.