git add .
git commit "feat: add last 10 days visits chart to dashboard"
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
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;
|
||||
@@ -21,15 +22,20 @@ class DashboardController extends Controller
|
||||
$flightsCount = Flight::count();
|
||||
|
||||
$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))
|
||||
->qroupBy('date')
|
||||
->groupBy('date')
|
||||
->orderBy('date')
|
||||
->get();
|
||||
|
||||
$logs = ActivityLog::with('admin')
|
||||
->latest()
|
||||
->take(5)
|
||||
->get();
|
||||
|
||||
return view('admin.dashboard',compact('adminsCount',
|
||||
'usersCount','toursCount','flightsCount','tourViews'
|
||||
,'logs'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<?php
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
@@ -1,62 +1,50 @@
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('breadcrumb')
|
||||
|
||||
<span>
|
||||
داشبورد
|
||||
</span>
|
||||
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
|
||||
<div class="container-fluid mt-4">
|
||||
|
||||
<div class="container-fluid">
|
||||
|
||||
|
||||
<h3 class="mb-4">
|
||||
<h3 class="mb-4 fw-bold">
|
||||
داشبورد مدیریت
|
||||
</h3>
|
||||
|
||||
|
||||
|
||||
<div class="row g-4">
|
||||
|
||||
|
||||
<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">
|
||||
|
||||
<h6>
|
||||
<h6 class="text-muted">
|
||||
مدیران
|
||||
</h6>
|
||||
|
||||
<h2>
|
||||
|
||||
<h2 class="fw-bold mt-3">
|
||||
{{ $adminsCount ?? 0 }}
|
||||
</h2>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<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">
|
||||
|
||||
<h6>
|
||||
<h6 class="text-muted">
|
||||
کاربران
|
||||
</h6>
|
||||
|
||||
<h2>
|
||||
<h2 class="fw-bold mt-3">
|
||||
{{ $usersCount ?? 0 }}
|
||||
</h2>
|
||||
|
||||
@@ -67,83 +55,159 @@
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<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">
|
||||
|
||||
<h6>
|
||||
<h6 class="text-muted">
|
||||
تورها
|
||||
</h6>
|
||||
|
||||
<h2>
|
||||
|
||||
<h2 class="fw-bold mt-3">
|
||||
{{ $toursCount ?? 0 }}
|
||||
</h2>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<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">
|
||||
|
||||
<h6>
|
||||
<h6 class="text-muted">
|
||||
پروازها
|
||||
</h6>
|
||||
|
||||
<h2>
|
||||
|
||||
<h2 class="fw-bold mt-3">
|
||||
{{ $flightsCount ?? 0 }}
|
||||
</h2>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="card shadow-sm mt-5">
|
||||
|
||||
<div class="card-header">
|
||||
|
||||
<div class="card shadow-sm border-0 mt-5">
|
||||
<div class="card-header bg-white fw-bold">
|
||||
آخرین فعالیتها
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="card-body">
|
||||
|
||||
<table class="table table-bordered text-center">
|
||||
|
||||
<p class="text-muted">
|
||||
هنوز فعالیتی ثبت نشده است.
|
||||
</p>
|
||||
<thead>
|
||||
|
||||
<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 class="card-body">
|
||||
<canvas id="viewsChart" height="100"></canvas>
|
||||
|
||||
</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
|
||||
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user