@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use App\Models\LodgeBooking;
|
||||
use App\Models\LodgePhoto;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::middleware(['auth', 'verified'])->prefix('admin')->group(function () {
|
||||
$isAdmin = static function ($request): void {
|
||||
abort_unless(
|
||||
filled(config('lodge.admin_email'))
|
||||
&& strcasecmp(trim((string) $request->user()?->email), trim((string) config('lodge.admin_email'))) === 0,
|
||||
403
|
||||
);
|
||||
};
|
||||
|
||||
Route::get('/', function (\Illuminate\Http\Request $request) use ($isAdmin) {
|
||||
$isAdmin($request);
|
||||
return view('lodge.admin-dashboard', [
|
||||
'total' => LodgeBooking::count(),
|
||||
'pending' => LodgeBooking::where('status', 'pending')->count(),
|
||||
'confirmed' => LodgeBooking::where('status', 'confirmed')->count(),
|
||||
'photoCount' => LodgePhoto::count(),
|
||||
'recent' => LodgeBooking::latest()->take(8)->get(),
|
||||
]);
|
||||
})->name('admin.dashboard');
|
||||
|
||||
Route::get('/photos', function (\Illuminate\Http\Request $request) use ($isAdmin) {
|
||||
$isAdmin($request);
|
||||
return view('lodge.admin-photos', ['photos' => LodgePhoto::latest()->get()]);
|
||||
})->name('admin.photos');
|
||||
});
|
||||
Reference in New Issue
Block a user