remodelled homecontroller a bit
This commit is contained in:
parent
ca685bd460
commit
a5750187d7
5 changed files with 28 additions and 29 deletions
|
@ -33,6 +33,7 @@ class HomeController extends Controller
|
|||
->orderBy('user_id', 'desc')
|
||||
->limit(1)
|
||||
->get(['user_id']);
|
||||
|
||||
$newestUser = User::construct($newestUserId ? $newestUserId[0]->user_id : 0);
|
||||
|
||||
// Get all the currently online users
|
||||
|
@ -58,28 +59,27 @@ class HomeController extends Controller
|
|||
$onlineUsers[$user->id] = $user;
|
||||
}
|
||||
|
||||
//$news = new Category(config('general.news'));
|
||||
$news = []; //new Category(config('general.news'));
|
||||
|
||||
Template::vars([
|
||||
'news' => [],
|
||||
'stats' => [
|
||||
'userCount' => DB::table('users')
|
||||
$userCount = DB::table('users')
|
||||
->where('rank_main', '!=', config('rank.banned'))
|
||||
->where('user_activated', 1)
|
||||
->where('user_restricted', 0)
|
||||
->count(),
|
||||
'newestUser' => $newestUser,
|
||||
'lastRegDate' => date_diff(
|
||||
->count();
|
||||
|
||||
$lastRegDate = date_diff(
|
||||
date_create(date('Y-m-d', $newestUser->registered)),
|
||||
date_create(date('Y-m-d'))
|
||||
)->format('%a'),
|
||||
'topicCount' => DB::table('topics')->where('forum_id', '!=', config('forum.trash'))->count(),
|
||||
'postCount' => DB::table('posts')->where('forum_id', '!=', config('forum.trash'))->count(),
|
||||
'onlineUsers' => $onlineUsers,
|
||||
],
|
||||
]);
|
||||
)->format('%a');
|
||||
|
||||
// Return the compiled page
|
||||
return Template::render('meta/index');
|
||||
$trashId = config('forum.trash');
|
||||
$topicCount = DB::table('topics')
|
||||
->where('forum_id', '!=', $trashId)
|
||||
->count();
|
||||
$postCount = DB::table('posts')
|
||||
->where('forum_id', '!=', $trashId)
|
||||
->count();
|
||||
|
||||
return view('home/index', compact('news', 'userCount', 'newestUser', 'lastRegDate', 'topicCount', 'postCount', 'onlineUsers'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,14 +21,14 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
<div class="content__header content__header--alt">Stats</div>
|
||||
We have <b>{{ stats.userCount }} user{% if stats.userCount != 1 %}s{% endif %}</b>,
|
||||
<b><a href="{{ route('user.profile', stats.newestUser.id) }}" style="color: {{ stats.newestUser.colour }};">{{ stats.newestUser.username }}</a></b> is the newest user,
|
||||
it has been <b>{{ stats.lastRegDate }} day{{ stats.lastRegDate == 1 ? '' : 's' }}</b> since the last user registered and the forum has <b>{{ stats.topicCount }} topic{% if stats.topicCount != 1 %}s{% endif %}</b> and <b>{{ stats.postCount }} post{% if stats.postCount != 1 %}s{% endif %}</b>.
|
||||
We have <b>{{ userCount }} user{% if userCount != 1 %}s{% endif %}</b>,
|
||||
<b><a href="{{ route('user.profile', newestUser.id) }}" style="color: {{ newestUser.colour }};">{{ newestUser.username }}</a></b> is the newest user,
|
||||
it has been <b>{{ lastRegDate }} day{{ lastRegDate == 1 ? '' : 's' }}</b> since the last user registered and the forum has <b>{{ topicCount }} topic{% if topicCount != 1 %}s{% endif %}</b> and <b>{{ postCount }} post{% if postCount != 1 %}s{% endif %}</b>.
|
||||
<div class="content__header content__header--alt">Online Users</div>
|
||||
{% if stats.onlineUsers %}
|
||||
{% if onlineUsers %}
|
||||
All active users in the past 2 minutes
|
||||
<table class="sidepanel-table">
|
||||
{% for amount, onlineUser in stats.onlineUsers %}
|
||||
{% for amount, onlineUser in onlineUsers %}
|
||||
<tr>
|
||||
<td class="sidepanel-table__column sidepanel-table__column--align-left">
|
||||
<a href="{{ route('user.profile', onlineUser.id) }}" style="font-weight: bold; color: {{ onlineUser.colour }};">
|
|
@ -126,7 +126,7 @@
|
|||
|
||||
Yuuno.Main.Startup();
|
||||
|
||||
{% if config('dev.show_changelog') and stats is defined %}
|
||||
{% if config('dev.show_changelog') and server['REQUEST_URI'] == '/' %}
|
||||
Sakura.Changelog.Build(Sakura.DOM.ID('indexPanel'));
|
||||
{% endif %}
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
{% extends 'master.twig' %}
|
|
@ -18,7 +18,7 @@ Router::filter('maintenance', function () {
|
|||
});
|
||||
|
||||
Router::group(['before' => 'maintenance'], function () {
|
||||
// Meta pages
|
||||
// Homepage
|
||||
Router::get('/', 'HomeController@index', 'main.index');
|
||||
|
||||
// Link compatibility layer, prolly remove this in like a year
|
||||
|
|
Reference in a new issue