mirror of
https://github.com/ericasch6/scrum-poker-internal.git
synced 2026-10-13 17:12:08 +00:00
35 lines
1000 B
PHP
35 lines
1000 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Room;
|
|
use Illuminate\Http\Request;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
class DashboardController extends Controller
|
|
{
|
|
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(),
|
|
]);
|
|
|
|
return Inertia::render('Dashboard', [
|
|
'rooms' => $rooms,
|
|
]);
|
|
}
|
|
}
|