public static function catlist() { $model = ForumCategory::find()->where(['status' => 1])->all(); $result = []; foreach ($model as $data) { $result[$data->id] = $data->name; } return $result; }
<table class="table table-striped"> <thead> <tr> <th class="col-lg-1">Тип</th> <th class="col-lg-7">Тема</th> <th class="col-lg-1">Сообщения</th> <th class="col-lg-2">Раздел</th> <th class="col-lg-1">Управление</th> </tr> </thead> <tbody> <?php foreach ($model as $post) { ?> <?php $category = \app\models\ForumCategory::find()->where(['id' => $post->category])->one(); $messagesCount = \app\models\ForumMessage::find()->where(['post_id' => $post->id])->count(); $lastMessage = \app\models\ForumMessage::find()->where(['post_id' => $post->id])->orderBy('id desc')->select('dateadd')->one(); if (!$lastMessage) { $lastMessage['dateadd'] = 1; } if ($lastMessage['dateadd'] == time()) { $mailIcon = 4; $mailTitle = 'Есть новые ответы'; } else { if ($messagesCount > 50) { $mailIcon = 3; $mailTitle = 'Популярная тема'; } else { if ($messagesCount > 10) { $mailIcon = 2;