git add .

git commit "feat: add last 10 days visits chart to dashboard"
This commit is contained in:
2026-08-19 15:29:11 +03:30
parent 4d8839e802
commit 50bb856b24
6 changed files with 126 additions and 61 deletions
@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Admin\Auth; namespace App\Http\Controllers\Admin\Auth;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\ActivityLog;
use App\Models\Admin; use App\Models\Admin;
use App\Models\Flight; use App\Models\Flight;
use App\Models\Tour; use App\Models\Tour;
@@ -21,15 +22,20 @@ class DashboardController extends Controller
$flightsCount = Flight::count(); $flightsCount = Flight::count();
$tourViews= Tour::query() $tourViews= Tour::query()
->selectRaw('DATE(create_at) as date,SUM(views) as total') ->selectRaw('DATE(created_at) as date,SUM(views) as total')
->where('created_at','>=',now()->subDays(9)) ->where('created_at','>=',now()->subDays(9))
->qroupBy('date') ->groupBy('date')
->orderBy('date') ->orderBy('date')
->get(); ->get();
$logs = ActivityLog::with('admin')
->latest()
->take(5)
->get();
return view('admin.dashboard',compact('adminsCount', return view('admin.dashboard',compact('adminsCount',
'usersCount','toursCount','flightsCount','tourViews' 'usersCount','toursCount','flightsCount','tourViews'
,'logs'
)); ));
} }
} }
+1
View File
@@ -0,0 +1 @@
<?php
Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

+117 -53
View File
@@ -1,62 +1,50 @@
@extends('admin.layouts.app') @extends('admin.layouts.app')
@section('breadcrumb') @section('breadcrumb')
<span> <span>
داشبورد داشبورد
</span> </span>
@endsection @endsection
@section('content') @section('content')
<div class="container-fluid mt-4">
<div class="container-fluid"> <h3 class="mb-4 fw-bold">
<h3 class="mb-4">
داشبورد مدیریت داشبورد مدیریت
</h3> </h3>
<div class="row g-4"> <div class="row g-4">
<div class="col-md-3"> <div class="col-md-3">
<div class="card dashboard-card shadow-sm"> <div class="card shadow-sm border-0 h-100">
<div class="card-body"> <div class="card-body">
<h6> <h6 class="text-muted">
مدیران مدیران
</h6> </h6>
<h2>
<h2 class="fw-bold mt-3">
{{ $adminsCount ?? 0 }} {{ $adminsCount ?? 0 }}
</h2> </h2>
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<div class="card dashboard-card shadow-sm"> <div class="card shadow-sm border-0 h-100">
<div class="card-body"> <div class="card-body">
<h6> <h6 class="text-muted">
کاربران کاربران
</h6> </h6>
<h2> <h2 class="fw-bold mt-3">
{{ $usersCount ?? 0 }} {{ $usersCount ?? 0 }}
</h2> </h2>
@@ -67,83 +55,159 @@
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<div class="card dashboard-card shadow-sm"> <div class="card shadow-sm border-0 h-100">
<div class="card-body"> <div class="card-body">
<h6> <h6 class="text-muted">
تورها تورها
</h6> </h6>
<h2>
<h2 class="fw-bold mt-3">
{{ $toursCount ?? 0 }} {{ $toursCount ?? 0 }}
</h2> </h2>
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<div class="card dashboard-card shadow-sm"> <div class="card shadow-sm border-0 h-100">
<div class="card-body"> <div class="card-body">
<h6> <h6 class="text-muted">
پروازها پروازها
</h6> </h6>
<h2>
<h2 class="fw-bold mt-3">
{{ $flightsCount ?? 0 }} {{ $flightsCount ?? 0 }}
</h2> </h2>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="card shadow-sm border-0 mt-5">
<div class="card-header bg-white fw-bold">
<div class="card shadow-sm mt-5">
<div class="card-header">
آخرین فعالیت‌ها آخرین فعالیت‌ها
</div> </div>
<div class="card-body"> <div class="card-body">
<table class="table table-bordered text-center">
<p class="text-muted"> <thead>
هنوز فعالیتی ثبت نشده است.
</p>
<tr>
<th>کاربر</th>
<th>عملیات</th>
<th>بخش</th>
<th>تاریخ</th>
</tr>
</thead>
<tbody>
@forelse($logs as $log)
<tr>
<td>
{{ $log->admin->name ?? '-' }}
</td>
<td>
{{ $log->action }}
</td>
<td>
{{ $log->model }}
</td>
<td>
{{ $log->created_at->toJalali()->format('Y/m/d H:i') }}
</td>
</tr>
@empty
<tr>
<td colspan="4">
فعالیتی ثبت نشده است
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
<div class="card shadow-sm border-0 mt-5">
<div class="card-header bg-white fw-bold">
نمودار بازدید تورها در ۱۰ روز اخیر
</div> </div>
<div class="card-body">
<canvas id="viewsChart" height="100"></canvas>
</div>
</div> </div>
</div> </div>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
const ctx = document.getElementById('viewsChart');
new Chart(ctx, {
type: 'bar',
data: {
labels: @json($tourViews->pluck('date')),
datasets: [{
label: 'بازدید تورها',
data: @json($tourViews->pluck('total')),
}]
},
options: {
responsive:true,
plugins:{
legend:{
position:'top'
}
},
scales:{
y:{
beginAtZero:true
}
}
}
});
</script>
@endsection @endsection
@@ -1,3 +0,0 @@
<div>
<!-- Simplicity is the essence of happiness. - Cedric Bledsoe -->
</div>
@@ -1,3 +0,0 @@
<div>
<!-- Nothing worth having comes easy. - Theodore Roosevelt -->
</div>