Example #1
0
 /**
  * Finds the Grupavid model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Grupavid the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Grupavid::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #2
0
 public function actionDelete($id)
 {
     if (Yii::$app->request->isAjax) {
         $transaction = Yii::$app->db->beginTransaction();
         try {
             Grupavid::deleteAll(['id_grupa' => $id]);
             echo $this->findModel($id)->delete();
             $transaction->commit();
         } catch (Exception $e) {
             $transaction->rollBack();
             throw new Exception($e->getMessage());
         }
     }
 }
Example #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Grupavid::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $query->joinWith(['idmatvid']);
     $this->load($params);
     $this->id_grupa = $params['id'];
     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(['grupavid_id' => $this->grupavid_id, 'grupavid_main' => $this->grupavid_main, 'id_grupa' => $this->id_grupa, 'id_matvid' => $this->id_matvid]);
     $query->andFilterWhere(['LIKE', 'idmatvid.matvid_name', $this->getAttribute('idmatvid.matvid_name')]);
     Proc::AssignRelatedAttributes($dataProvider, ['idmatvid.matvid_name']);
     return $dataProvider;
 }
Example #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getGrupavids()
 {
     return $this->hasMany(Grupavid::className(), ['id_matvid' => 'matvid_id'])->from(['grupavids' => Grupavid::tableName()]);
 }
Example #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdgrupavid()
 {
     return $this->hasMany(Grupavid::className(), ['id_grupa' => 'grupa_id'])->from(['idgrupavid' => Grupavid::tableName()]);
 }
Example #6
0
 /**
  * @depends loadData
  */
 public function destroyData()
 {
     Grupavid::deleteAll();
     Grupa::deleteAll();
     Matvid::deleteAll();
 }