fix: refactored the codebase

This commit is contained in:
2026-08-20 23:00:47 +02:00
parent 6f47ed0674
commit a77f74911d
64 changed files with 2864 additions and 1739 deletions
+16 -17
View File
@@ -2,33 +2,32 @@
namespace App\Http\Controllers;
use App\Models\Room;
use App\Http\Resources\DashboardRoomResource;
use App\Models\User;
use App\Services\Rooms\DashboardRoomService;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
class DashboardController extends Controller
{
public function __construct(
private readonly DashboardRoomService $dashboardRooms,
) {}
public function __invoke(Request $request): Response
{
$rooms = $request->user()
->ownedRooms()
->withCount('players')
->orderByRaw('closed_at IS NOT NULL')
->orderByDesc('last_activity_at')
->get()
->map(fn (Room $room) => [
'id' => $room->id,
'title' => $room->title,
'join_code' => $room->join_code,
'current_round' => $room->current_round,
'players_count' => $room->players_count,
'last_activity_at' => $room->last_activity_at?->toIso8601String(),
'closed_at' => $room->closed_at?->toIso8601String(),
]);
$user = $request->user();
abort_unless($user instanceof User, 403);
$rooms = $this->dashboardRooms->forUser($user);
return Inertia::render('Dashboard', [
'rooms' => $rooms,
'rooms' => DashboardRoomResource::collection($rooms['owned'])
->resolve($request),
'favoriteRooms' => DashboardRoomResource::collection($rooms['favorites'])
->resolve($request),
]);
}
}