I am overriding the find method and add the where condition globally thats working fine here is my code
class Order extends \common\components\ActiveRecord
\common\components\ActiveRecord
namespace common\components;
use Yii;
use yii\db\ActiveRecord as BaseActiveRecord;
class ActiveRecord extends BaseActiveRecord{
public static function find() {
return parent::find()
->where(['=',static::tableName().'.company_id',Yii::$app->user->identity->company_id])
->andWhere(['=',static::tableName().'.branch_id',Yii::$app->user->identity->branch_id]);
}
}
The find is not working when i call the model from view like this
echo \common\models\Order::find()->where(['status'=>'0'])->count();