I have to override the method using
namespace common\models;
use Yii;
use yii\db\ActiveQuery;
class Addfindcondition extends ActiveQuery
{
public function init()
{
$this->andOnCondition([$this->modelClass::tableName() . '.branch_id' => Yii::$app->user->identity->branch_id ]);
parent::init();
}
}
And call the method in each model separately like this
public static function find()
{
return new Addfindcondition(get_called_class());
}
Now I want to override the find method globally. How it is possible that I dont need to use this static method in each model