Answer the question
In order to leave comments, you need to log in
How to override find()->all()?
There is a Document model . There are two models DocumentIn and DocumentOut , extending the first one. The records in the table are distinguished by the kind field .
class DocumentIn extends Document
{
...
public static function find()
{
Yii::warning(get_called_class());
return new DocumentInQuery(get_called_class());
}
...
}
class DocumentInQuery extends \yii\db\ActiveQuery
{
public function active()
{
$this->andWhere('=0');
return $this;
}
public function all($db = null)
{
return parent::all($db);
}
public function one($db = null)
{
return parent::one($db);
}
}
Answer the question
In order to leave comments, you need to log in
public function all($db = null)
{
$this->active();
return parent::all($db);
}
public function init()
{
parent::init();
$this->active();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question