I have a method in a model like this:
class Poet extends \Phalcon\Mvc\Model
{
public function getFullName()
{
return $this->firstName . ' ' . $this->lastName;
}
}
In my controller I tried to do
$poets = Poet::find();
$i = 0;
foreach($poets as $poet) {
$fullName = $poet->getFullName();
$output['poets'][$i] = array(
'id' => $poet->id,
'name' => $fullName,
);
$i ++;
}
$this->view->setVars($output);
But it seems items in resultset is not an instance of Poet but instance of Model\Row
cause it says:
Call to undefined method Phalcon\Mvc\Model\Row::getFullName() in .......
My question is, how should I do something like this, or is there any way to get the instance of the model of a row object?