Example #1
0
    public function getCompanyDetails(){

        return (new Query())->select(
            '('.(new Query())->select('count(*)')->from(Auctions::tableName())->where(['company' => $this->id])->createCommand()->rawSql.') as companyAuctions,'.
            '('.(new Query())->select('count(*)')->from(CompanyUsers::tableName())->where('company=:c and user!=:u',[':c' => $this->id , ':u' => Auction::$app->user->id])->createCommand()->rawSql.') as companyUsers,'.
            '('.(new Query())->select('count(*)')->from(DealerCompany::tableName())->where(['company' => $this->id])->createCommand()->rawSql.') as companyDealers'
        )->one();

    }
Example #2
0
 public function getCompany(){
     return $this->hasOne(Companies::className(),['id' => 'company'])->viaTable(CompanyUsers::tableName(),['user' => 'id']);
 }