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 describe?

In my model I have this:

switch(intval($this->onsellid)){ case 8: $this->onsellid = '第一'; break; case 38: $this->onsellid = '第而'; break; }

how to describe my field

Hey, can you provide a little more info? What do you want to do with your code and what do you mean with describe?



27.0k

thanks for your reply, and in my model Users where have a field named 'audit' and it's value is Int (1,2,3....). But in my view(volt) I will show it as 1-Approve,2-Unapprove,3-commit.... so there will many description and I will change it sometime. so I dont want to define it in view, I want to define it in model so when I find a model it outo change as description as CI do.



93.7k
Accepted
answer
edited Oct '15

Hey, i think this will do the work for you:

Controller code:

foreach (NewsCategories::find() as $item) {
    echo $item->getIsActive() . '<br/>';
}
exit;

Model (here you can put your switch clause from your first comment:

public function getIsActive()
{
    // replace this logic with your switch and return result;
    return $this->is_active ? 'Yes' : 'No';
}    

Thats an example from my project. In my DB i store is_active as 0/1 and with this example i get this as print results

Yes
Yes
No
Yes