save to codehub
This commit is contained in:
36
app/Http/Controllers/Admin/DashboardController.php
Normal file
36
app/Http/Controllers/Admin/DashboardController.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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')
|
||||
->whereHas('user')
|
||||
->orderBy('total_score', 'desc') // Use 'asc' for ascending order
|
||||
->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]);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user