コード例 #1
0
ファイル: SearchUserGroup.php プロジェクト: jflash49/TSS
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = UserGroup::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'owner_id' => $this->owner_id]);
     $query->andFilterWhere(['like', 'participants', $this->participants])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
コード例 #2
0
 public function saveAll()
 {
     $__models = UserGroup::findAll(['userId' => $this->Id]);
     if (is_array($__models)) {
         $groups = $this->groupMap;
         foreach ($__models as $index => $model) {
             if (isset($groups[$index])) {
                 $model->groupId = $groups[$index];
                 $flag = $model->save();
                 unset($groups[$index]);
             } else {
                 $model->delete();
             }
             if (!$flag) {
                 break;
             }
         }
         foreach ($groups as $groupId) {
             //new insert
             $model = new UserGroup();
             $model->groupId = $groupId;
             $model->userId = $this->Id;
             $flag = $model->save();
             if (!$flag) {
                 break;
             }
         }
     } else {
         //new insertion
         foreach ($this->groupMap as $groupId) {
             $model = new UserGroup();
             $model->groupId = $groupId;
             $model->userId = $this->Id;
             $flag = $model->save();
             if (!$flag) {
                 break;
             }
         }
     }
     return $flag;
 }
コード例 #3
0
ファイル: Group.php プロジェクト: rajanishtimes/partnerapi
 public function getMapedUsers()
 {
     return $this->hasMany(UserGroup::className(), ['groupId' => 'Id']);
 }
コード例 #4
0
ファイル: UserGroupController.php プロジェクト: jflash49/TSS
 /**
  * Finds the UserGroup model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return UserGroup the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = UserGroup::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #5
0
 public function getUsersGroup()
 {
     return $this->usergroupsDP = new ActiveDataProvider(['query' => UserGroup::find()->where(['userId' => $this->Id])]);
 }