Files
hatame.andarza09/app/Http/Controllers/Admin/Auth/DashboardController.php
T
hatame 3f46f6356a git add .
git commit "fix(assets): self-host Chart.js instead of loading from CDN"
2026-08-19 17:03:59 +03:30

49 lines
1.2 KiB
PHP

<?php
namespace App\Http\Controllers\Admin\Auth;
use App\Http\Controllers\Controller;
use App\Models\ActivityLog;
use App\Models\Admin;
use App\Models\Flight;
use App\Models\Tour;
use App\Models\User;
class DashboardController extends Controller
{
public function index()
{
$adminsCount = Admin::count();
$usersCount = User::count();
$toursCount = Tour::count();
$flightsCount = Flight::count();
$tourViews= Tour::query()
->selectRaw('DATE(created_at) as date,SUM(views) as total')
->where('created_at','>=',now()->subDays(9))
->groupBy('date')
->orderBy('date')
->get();
$flightViews=Flight::query()
->selectRaw('DATE(created_at) as date,SUM(views) as total')
->where('created_at','>=',now()->subDays(9))
->groupBy('date')
->orderBy('date')
->get();
$logs = ActivityLog::with('admin')
->latest()
->take(5)
->get();
return view('admin.dashboard',compact('adminsCount',
'usersCount','toursCount','flightsCount','tourViews',
'flightViews','logs'
));
}
}