feat: implement site visit in controller and add visit table
This commit is contained in:
@@ -6,15 +6,31 @@ use App\Http\Controllers\Controller;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Flight;
|
||||
use App\Models\User;
|
||||
use App\Models\Visit;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$flightsCount = Flight::count();
|
||||
$usersCount = User::count();
|
||||
$bookingsCount = Booking::count();
|
||||
|
||||
return view('admin.dashboard', compact('flightsCount', 'usersCount', 'bookingsCount'));
|
||||
$startDate = Carbon::now()->subDays(9)->startOfDay();
|
||||
$endDate = Carbon::now()->endOfDay();
|
||||
|
||||
|
||||
$flightsCount = Flight::count();
|
||||
$usersCount = User::count();
|
||||
$bookingsCount = Booking::count();
|
||||
$indexPageCont = Visit::count();
|
||||
|
||||
$visits = Visit::whereBetween('created_at', [$startDate, $endDate])
|
||||
->selectRaw('DATE(created_at) as visit_date, COUNT(*) as total')
|
||||
->groupBy('visit_date')
|
||||
->orderBy('visit_date')
|
||||
->get();
|
||||
|
||||
|
||||
return view('admin.dashboard', compact('flightsCount', 'usersCount',
|
||||
'bookingsCount', 'indexPageCont' , 'visits'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user