/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params, $id_dev = 0) { if ($id_dev == 0) { $query = StoryDevice::find(); } else { $query = StoryDevice::find()->where(['id_device' => $id_dev]); } $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, 'id_device' => $this->id_device, 'id_wp' => $this->id_wp, 'date_up' => $this->date_up, 'event' => $this->event]); return $dataProvider; }
/** * Finds the StoryDevice model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return StoryDevice the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = StoryDevice::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Удаляем историю по идентификатору устройства * @param $id_dev */ public function delStory($id_dev) { StoryDevice::deleteAll(['id_device' => $id_dev]); }
/** * Deletes an existing Devices model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { if ($this->findModel($id)->delete()) { StoryDevice::delStory($id); } return $this->redirect(['index']); }