We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Model::query Left join getting model not loaded error.

So here is my query.

use Nova\Models\Accounts;
use Nova\Models\AccountStatus;

public function indexAction(){
  $statusCount = AccountStatus::query()
  ->leftJoin('Accounts','a.id = AccountStatus.accountId','a')
  ->where('a.userId = :id:')
  ->bind(array('id' => 1)) // 1 is test value
  ->execute();
}

Getting this error:

Phalcon\Mvc\Model\Exception: Model 'Accounts' could not be loaded /nova/app/controllers/DashboardController.php (44)



34.6k
Accepted
answer

Model names inside strings aren't resolved by PHP: https://php.net/manual/en/language.namespaces.importing.php