Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Items::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, 'cat_id' => $this->cat_id, 'brend_id' => $this->brend_id, 'material' => $this->material, 'pie' => $this->pie, 'lad' => $this->lad, 'inlay' => $this->inlay, 'q_volume' => $this->q_volume, 'q_tone' => $this->q_tone]);
     $query->andFilterWhere(['like', 'strings', $this->strings])->andFilterWhere(['like', 'anker', $this->anker])->andFilterWhere(['like', 'form', $this->form])->andFilterWhere(['like', 'bridj', $this->bridj])->andFilterWhere(['like', 'shema', $this->shema])->andFilterWhere(['like', 'add', $this->add]);
     return $dataProvider;
 }
Example #2
0
 public function actionGalary()
 {
     //$modelPhoto = Photo::find()->all();
     $modelPhoto = Items::find()->where('main_image <> 0')->all();
     return $this->render('galary2', ['modelPhoto' => $modelPhoto]);
 }
Example #3
0
 public function actionDeleteImageMain()
 {
     $id = Yii::$app->request->post('id');
     //vd($id);
     $model = Items::find()->where(['id' => $id])->one();
     //vd($model);
     $Name = $model->main_image;
     //vd($Name);
     $model->main_image = '';
     $model->updateAttributes(['main_image']);
     // найти картику и удалить
     $uploaddir = Yii::getAlias('@frontend') . '/web/upload/items_images_main/';
     $filename = $uploaddir . $Name;
     if (!@unlink($filename)) {
         die('Error Delete File.');
     }
 }