Ejemplo n.º 1
0
 /**
  * Finds the Error model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Error the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Error::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 2
0
 /**
  * Searches models.
  * @param array $params search params
  * @return \yii\data\ActiveDataProvider dataProvider
  */
 public function search($params)
 {
     $t = self::tableName();
     $query = Error::find();
     $query->orderBy(["{$t}.log_time" => SORT_DESC]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere([$t . '.id' => $this->id, $t . '.level' => $this->level]);
     $query->andFilterWhere(['like', $t . '.category', $this->category])->andFilterWhere(['like', $t . '.prefix', $this->prefix])->andFilterWhere(['like', $t . '.message', $this->message]);
     if ($this->log_time) {
         $query->andWhere("DATE_FORMAT(FROM_UNIXTIME({$t}.log_time), '%Y-%m-%d') = :logTime")->addParams([':logTime' => $this->log_time]);
     }
     return $dataProvider;
 }
Ejemplo n.º 3
0
 /**
  * @inheritdoc
  */
 public function run($id)
 {
     Error::findOne($id)->delete();
     return $this->controller->redirect(['index']);
 }
Ejemplo n.º 4
0
 /**
  * @inheritdoc
  */
 public function run($id)
 {
     return $this->controller->render('view', ['model' => Error::findOne($id)]);
 }
Ejemplo n.º 5
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     Error::deleteAll();
     return $this->controller->redirect(['index']);
 }