?> <div class="panel panel-info"> <div class="panel-heading"> <h3 class="panel-title"><i class="fa fa-warning"></i> <?php echo Yii::t('maddoger/admin', 'System messages'); ?> <small><?php echo Html::a(Yii::t('maddoger/admin', 'more info'), ['system-messages/index']); ?> </small> </h3> </div> <!-- /.panel-header --> <div class="panel-body"> <?php $messages = SystemMessage::findLastMessages()->limit(10)->all(); if ($messages) { foreach ($messages as $message) { $options = ['class' => 'callout']; if ($message['type']) { Html::addCssClass($options, 'callout-' . $message['type']); } echo Html::tag('div', Html::tag('h4', $message->title) . Html::tag('span', Yii::$app->formatter->asDatetime($message->created_at), ['class' => 'small text-muted']) . Html::tag('p', $message->message), $options); } } else { echo '<p class="text-muted">' . Yii::t('maddoger/admin', 'No messages found.') . '</p>'; } ?> </div> <!-- /.panel-body --> </div>
/** * @return string */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => SystemMessage::findLastMessages(0)]); $dataProvider->sort->defaultOrder = ['created_at' => SORT_DESC]; return $this->render('index', ['dataProvider' => $dataProvider]); }