From 319b312b23dd66e2c8c01d9fffb1034d8c3fceb4 Mon Sep 17 00:00:00 2001 From: Floorb <132411956+Neetpone@users.noreply.github.com> Date: Mon, 15 May 2023 11:41:35 -0400 Subject: [PATCH] fix: various admin dashboard improvements. --- includes/Models/User.php | 2 +- public/admin/dashboard.php | 80 +++++++++++++++++++++----------------- 2 files changed, 45 insertions(+), 37 deletions(-) diff --git a/includes/Models/User.php b/includes/Models/User.php index c7bf6bd..32b791d 100644 --- a/includes/Models/User.php +++ b/includes/Models/User.php @@ -9,7 +9,7 @@ class User extends Model { protected $table = 'users'; protected $fillable = [ - 'username', 'password', 'recovery_code_hash' + 'username', 'password', 'recovery_code_hash', 'ip' ]; public function session() { diff --git a/public/admin/dashboard.php b/public/admin/dashboard.php index f7bb2e8..7fbc6f9 100644 --- a/public/admin/dashboard.php +++ b/public/admin/dashboard.php @@ -1,6 +1,6 @@ orderBy('id', 'desc') - ->first(); + ->orderBy('id', 'desc') + ->first(); $today_page = $last_page_view->tpage; $today_visit = $last_page_view->tvisit; @@ -25,7 +25,6 @@ $today_users_count = User::where(['created_at' => 'TODAY()'])->count(); /* Number of pastes today */ $today_pastes_count = Paste::where(['created_at' => 'TODAY()'])->count(); - foreach (PageView::orderBy('id', 'desc')->take(7)->get() as $row) { $sdate = $row['date']; $sdate = str_replace(date('Y'), '', $sdate); @@ -44,13 +43,24 @@ foreach (PageView::orderBy('id', 'desc')->take(7)->get() as $row) { $tvisit[] = $row['tvisit']; } -$admin_histories = AdminLog::with('user')->orderBy('id', 'desc')->take(10)->get(); +$admin_histories = AdminLog::with('user') + ->orderBy('id', 'desc') + ->take(10) + ->get(); + +$most_recent_users = User::select('id', 'username', 'created_at', 'ip') + ->orderBy('id', 'desc') + ->limit(7) + ->get(); function getRecentadmin($count = 5) { return Paste::with('user') - ->orderBy('id') - ->limit($count)->get(); + ->orderBy('id', 'desc') + ->limit($count)->get(); } + +$is_admin = $current_user->role >= User::ROLE_ADMIN; + ?> @@ -75,7 +85,7 @@ function getRecentadmin($count = 5) {