public function getTeam(){
if($this->getIsLeader())
return $this->hasMany(self::className(), ['team_id'=>'id']);
else{
return User::find()->where(['id'=>$this->team_id])->one()->getTeam()->where('id != :uid', [':uid'=>$this->id])
->union($this->hasOne(self::className(), ['id'=>'team_id']));
}
}
public function getTeam_count(){
return $this->getTeam()->count();
}
(SELECT * FROM `user` WHERE (id != 8538) AND (`team_id`=1)) UNION ( SELECT * FROM `user` WHERE `id`=1 )
'columns' => [
[
'attribute' => 'name',
'format' => 'html',
'value' => function ($model) {
return Html::a(
'<img src="'.Media::preview($model->image_id,100,100).'" class="pull-left img-thumbnail" />'
. $model->name,
['/club/view', 'club_id'=>$model->id]
);
}
],
[
'attribute' => 'city_id',
'format' => 'html',
'value' => function ($model) {
return $model->city->name;
}
],
'members_count',
[
'attribute' => 'type',
'format' => 'text',
'value' => function ($model) {
return \app\models\Club::$types[ $model->type ];
}
],
]