Exemplo n.º 1
0
 /**
  * Finds the Log model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Log the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Log::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException(Yii::t('maddoger/admin', 'The requested system message does not exist.'));
     }
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Log::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->defaultOrder = ['log_time' => SORT_DESC];
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'level' => $this->level]);
     $query->andFilterWhere(['like', 'category', $this->category])->andFilterWhere(['like', 'prefix', $this->prefix])->andFilterWhere(['like', 'message', $this->message]);
     //Smart log time filter
     if ($this->log_time) {
         $startTime = strtotime($this->log_time);
         if ($startTime !== false) {
             $query->andWhere(['>=', 'log_time', $startTime]);
         }
     }
     return $dataProvider;
 }
Exemplo n.º 3
0
 /**
  * @return string
  */
 public function actionIndex()
 {
     $view = Module::getInstance()->dashboardView ?: 'dashboard';
     return $this->render($view, ['menu' => Module::getInstance()->getSidebarMenu(), 'messages' => Yii::$app->user->can('admin.log') ? Log::findLastMessages()->limit(10)->all() : false]);
 }