I want to create a function in model that return a string. so for example function stringReturn() { print("randomText") }
I created a createAction() in the controller, for example public function createAction() { $user = new Example(); $user -> id = "1"; $user -> name = "john"; result = $user -> save(); if (!$result) { print_r($user -> getMessages()); } }
I created a beforeCreate function inside the model of Example
public function beforeCreate() { $this->return_string = stringReturn(); }
so ultimately, each time i run the URL to create a new user, I want return_string (inside the database) to have the value of "randomText" which is generated from the function above.
however, i am getting the error of Fatal error: Call to undefined function"
I am new to Phalcon framework so please excuse my lack of knowledge. Thank you all.