Added Notifications
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
use App\Models\IgnoredMissingLivery;
|
||||
use App\Models\User;
|
||||
use App\Models\UserFlight;
|
||||
use App\Services\AdminService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class AdminController extends Controller
|
||||
{
|
||||
|
||||
public function __construct(private readonly AdminService $adminService){}
|
||||
|
||||
function staticAdminData(){
|
||||
return [
|
||||
'missingLiveryCount' => $this->adminService->getMissingLiveries()->count(),
|
||||
];
|
||||
}
|
||||
|
||||
function dashboard(){
|
||||
return inertia('Admin/Dashboard', [
|
||||
'title' => 'Admin Control Panel',
|
||||
'userCount' => User::count(),
|
||||
'oneWeekUserGrowth' => User::where('created_at', '>=', Carbon::now()->subWeek())->count(),
|
||||
'flightCount' => UserFlight::count(),
|
||||
'oneWeekFlightGrowth' => UserFlight::where('created_at', '>=', Carbon::now()->subWeek())->count(),
|
||||
'latestUser' => User::latest()->first()->name,
|
||||
...$this->staticAdminData(),
|
||||
]);
|
||||
}
|
||||
|
||||
function reconcileMissingLiveries(){
|
||||
$missingLiveries = $this->adminService->getMissingLiveries();
|
||||
|
||||
return Inertia::render('Admin/MissingLiveries', [
|
||||
'title' => $missingLiveries->count() . ' Missing Liveries',
|
||||
'missingLiveries' => $missingLiveries,
|
||||
...$this->staticAdminData(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function ignoreMissingLivery(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'filename' => 'required|string',
|
||||
]);
|
||||
|
||||
IgnoredMissingLivery::createOrFirst($validated);
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user