33 lines
958 B
PHP
33 lines
958 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use App\Models\User;
|
|
use App\Models\LeaderboardMaster;
|
|
use Auth;
|
|
|
|
class DashboardController extends Controller
|
|
{
|
|
// public function index(){
|
|
//// $userCount = User::count();
|
|
// return view('Admin.dashboard')->with(['user_count' => $userCount]);
|
|
// }
|
|
|
|
public function view_dashboard() {
|
|
// dd(Auth::user());
|
|
$manage_dashboard = LeaderboardMaster::with('user')->get()->toArray();
|
|
// echo "<pre>";
|
|
// print_r($manage_dashboard);
|
|
// exit();
|
|
|
|
// Sort the $manage_dashboard array by the 'total_score' attribute in descending order
|
|
usort($manage_dashboard, function($a, $b) {
|
|
return $b['total_score'] <=> $a['total_score'];
|
|
});
|
|
return view('Admin.dashboard')->with(['manage_dashboard' => $manage_dashboard]);
|
|
|
|
}
|
|
}
|