示例#1
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getGroupAssignments()
 {
     return $this->hasMany(GroupAssignments::className(), ['user_id' => 'id']);
 }
 /**
  * Finds the GroupAssignments model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return GroupAssignments the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = GroupAssignments::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function isUserAssignedToGroup($user_id, $group_id)
 {
     $groupAssignments = GroupAssignments::find()->where(['user_id' => $user_id, 'group_id' => $group_id])->all();
     return count($groupAssignments) > 0;
 }
示例#4
0
 protected function validateAssignExist($user_id)
 {
     if (($model = GroupAssignments::find()->where(['user_id' => $user_id, 'group_id' => $this->id])->one()) !== null) {
         return true;
     } else {
         return false;
     }
 }
 public function isGroupBelongToMember($group_id, $user_id)
 {
     $groupAssignments = GroupAssignments::find()->where(['user_id' => $user_id, 'group_id' => $group_id])->all();
     return count($groupAssignments) > 0;
 }