/**
  * Finds the Importmaterial model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Importmaterial the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Importmaterial::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Importmaterial::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['importmaterial_combination' => SORT_ASC]]]);
     $query->joinWith(['idmatvid']);
     $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(['importmaterial_id' => $this->importmaterial_id, 'id_matvid' => $this->id_matvid]);
     $query->andFilterWhere(['like', 'importmaterial_combination', $this->importmaterial_combination]);
     $query->andFilterWhere(['LIKE', 'idmatvid.matvid_name', $this->getAttribute('idmatvid.matvid_name')]);
     Proc::AssignRelatedAttributes($dataProvider, ['idmatvid.matvid_name']);
     return $dataProvider;
 }
Beispiel #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getImportmaterials()
 {
     return $this->hasMany(Importmaterial::className(), ['id_matvid' => 'matvid_id'])->from(['importmaterials' => Importmaterial::tableName()]);
 }