Binding where conditions for all CRUD

i need to bind for all my CRUD operations a dynamic where condition depends on user role, and i want to make this in one place if is possible



32.7k
edited Jun '14

check out "afterFetch" method in models. It might help. Eg: Create a base model and extend all your models from that one

class BaseModel extends \Phalcon\Mvc\Model
{
    public function afterFetch()
    {
        if ($this->user_role == 'admin') {
            // do something
        }
    }
}