/** * Verifica se existe pelo menos um membro admin */ public function existMemberAdmin() { $isAdmin = $this->user_type == \app\enum\UserType::Administrador_MemoBoard; if ($isAdmin) { return true; } $x = FamilyMember::find()->where(['user_type' => \app\enum\UserType::Administrador_MemoBoard])->andWhere(['family_id' => $this->family_id])->andWhere(['<>', 'id', $this->id])->count(); if ($x < 1) { $this->addError('user_type', 'Tem de existir na famÃlia pelo menos um membro ' . \app\enum\UserType::toName(\app\enum\UserType::Administrador_MemoBoard)); return false; } return true; }
public function actionMembers() { $dataProvider = new ActiveDataProvider(['query' => FamilyMember::find()->orderBy('family_id ASC'), 'pagination' => ['pageSize' => 20]]); return $this->render('members', array('dataProvider' => $dataProvider)); }
public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => FamilyMember::find()->where(['family_id' => yii::$app->user->identity->family_id])->orderBy('user_type DESC'), 'pagination' => ['pageSize' => 20]]); return $this->render('index', array('dataProvider' => $dataProvider)); }