Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Description::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(['desid' => $this->desid, 'date' => $this->date, 'tag' => $this->tag]);
     $query->andFilterWhere(['like', 'header', $this->header])->andFilterWhere(['like', 'art_body', $this->art_body])->andFilterWhere(['like', 'photo', $this->photo]);
     return $dataProvider;
 }
Example #2
0
 public function actionCreate()
 {
     $model = new Items();
     $upload = new UploadForm();
     $category = new Categories();
     $subCat = new SubCatgories();
     $category->find()->all();
     $subCat->find()->all();
     $model->is_aviable = 1;
     $description = new Description();
     $description->item_id = 1;
     $description->sub_id = 1;
     $description->text = "s";
     $description->save();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         if (isset($_POST['Description'])) {
             //                print_r($_POST['Description']['sub_name']);
             $subCat = new SubCatgories();
             $subCat->find()->where(['name' => $_POST['Description']['sub_name']])->all();
             $s = $subCat->find()->where(['name' => $_POST['Description']['sub_name']])->all();
             $description = new Description();
             $description->item_id = $model->id;
             $description->sub_id = $s[0]['id'];
             $description->text = $_POST['Description']['text'];
             $description->category_name = $_POST['Description']['category_name'];
             $description->sub_name = $_POST['Description']['sub_name'];
             $description->save();
             //                echo "sssss";
             //                echo $description->sub_id;
             //                echo $description->item_id;
         }
         if (isset($_POST['Description'])) {
             $upload = new UploadForm();
             $upload->imageFiles = UploadedFile::getInstances($upload, 'imageFiles');
             if ($upload->upload()) {
                 echo "upload";
                 // file is uploaded successfully
                 // return;
             }
         }
         //	else
         //      	return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'category' => $category, 'subCat' => $subCat, 'description' => $description, 'upload' => $upload]);
     }
 }
Example #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getDescriptions()
 {
     return $this->hasMany(Description::className(), ['tag' => 'tag_id']);
 }
 /**
  * Finds the Description model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Description the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Description::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #5
0
 public function joinDescTag()
 {
     $model = Description::find()->all();
     var_dump($model);
     die;
 }