Permanent params in related models

Hello,

in this document section http://docs.phalconphp.com/en/latest/reference/models.html#taking-advantage-of-relationships

shown how to add params

<?php $robotsParts = $robot->getRobotsParts("created_at = '2012-03-15'");  ?>

`

Is it possible to write in model these params permanently.

I overloaded query function

<?php
class Entity extends \Phalcon\Mvc\Model
{
    public static function query($dependencyInjector = NULL)
    {
        $criteria = parent::query($dependencyInjector);
        if (!$criteria->getDI()->get('user')->admin)
            $criteria->andWhere('deleted = 0');

        return $criteria;
    }
}

to always have WHERE deleted=0 on Entity::query() criteria, but I need to do same if I do $this->user->getEntity(). Do I need to overload __call method?

You could override the find() method, add your "deleted = 0" to the passed conditions, then call parent::find() with your newly modified conditions.

edited Aug '14

I tried to overload find() method, but it didn't work for me. So I overloaded __call method and added additional arguments.