How to extend dependent models between applications

Hi,

I am building applications based on yii2 advanced template.

My concern is here about finding a good way to extend dependent models.

Here is a simplified example:




class common/models/Company extends ActiveRecord






class common/models/CompanyCustomer extends common/models/Company

{

    //find customer type only

    public static function find()

    {

        return parent::find()->andOnCondition( ['@alias.companyType' => 1,] );

    }

}






class frontend/models/Company extends common/models/Company

{

    //find() method to restrict access to children companies only:

    public static function find()

    {

        return parent::find()->andOnCondition( ['@alias.parentid' => 1234,] );

    }

}



Now how could I do to access CompanyCustomer in the FRONTEND, having both find restrictions’?




find()

   ->andOnCondition( ['@alias.companyType' => 1,] )

   ->andOnCondition( ['@alias.parentid' => 1234,] );



Of course, I don’t want to duplicate code in a frontend/models/CompanyCustomer…

Not sure, if my question is clear enough. Don’t hesitate to give your thoughts!