Answer the question
In order to leave comments, you need to log in
Why can't Micro see the models?
There is an action in which I am trying to pull all the records from the table:
public function getAccounts() {
$accounts = Accounts::find();
return $this->response->setJsonContent(['accounts' => $accounts])->send();
}
<br />
<b>Warning</b>: class 'AdminController' does not have a method 'Accounts' in
<b>C:\OSPanel\domains\fisher.loc\public\index.php</b> on line
<b>20</b>
<br />
<?
use Phalcon\Mvc\Model;
class Accounts extends Model {
public $id;
public $login;
public $password;
}
Answer the question
In order to leave comments, you need to log in
In the loader, you need to register the namespace and the directory of the models
$loader = new \Phalcon\Loader();
$loader->registerNamespaces(
[
'App\\Models' => __DIR__ . '/models/',
]
);
$loader->registerDirs(
[
...
__DIR__ . '/models/',
...
]
)->register();
namespace App\Models;
class Accounts extends \Phalcon\Mvc\Model {
public $id;
public $login;
public $password;
public $steam_guard;
public $email;
public $worker_id;
}
use App\Models\Accounts;
class AdminController extends \Phalcon\Mvc\Controller {
public function getAccounts() {
$accounts = Accounts::find();
return $this->response->setJsonContent(['accounts' => $accounts])->send();
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question