Appendix to the table
-
Anyway, Phalcon is a frimevore. I need to register the user. In the counteraller, I write:
//AuthController.php Users::add($this->login,$this->password)
Users is the object of the model, the function adds the following:
//Users.php public function add($login,$password){ $this->login = $login; $this->password = $this->security->hash($password); return $this->save(); }
In this case, mistakes erupted
Call to undefined method AuthController::save()
Although the method to save is intended to be derived from the Users class, and more accurately from its parent /Phalcon\Mvc\Model. The user ' s additive in the Freimvor documentation is implemented in the counteraller, thus:
$users = new Users(); $users->login = $login; $users->password = $password; $users->save();
But I think it's not exactly the right thing to do with MVC. I think the addition itself should be in the module. And then it's easier, you don't have to write these lines, but just users:add, like when I'm going to make the hell. Can you please show me how you can make it possible to keep in the module? Or maybe I'm wrong, and the addition in the fashion only makes the ends?
-
You're in the AuthController, causing method( save). Like you write:
But I think it's not exactly the right thing to do with MVC.
Do you think it's wrong? From the point of view of MVC, the model works with the OBD rather than the controller. You have to call the Users model, and then you have to save the method. The documentation is correct. It's just that code you're getting a counteroler with his variable login and passwords from the model, in this case Users, and you're causing the method save(s) in the counteraller, as it was said.