mirror of
https://github.com/ericasch6/scrum-poker-internal.git
synced 2026-10-13 18:12:09 +00:00
fix: refactored the codebase
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Data\Rooms\RoomPageData;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class RoomResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
/** @var RoomPageData $pageData */
|
||||
$pageData = $this->resource;
|
||||
$room = $pageData->room;
|
||||
|
||||
return [
|
||||
'id' => $room->id,
|
||||
'title' => $room->title,
|
||||
'join_code' => $room->join_code,
|
||||
'owner_id' => $room->owner_id,
|
||||
'is_favorite' => $pageData->isFavorite,
|
||||
'current_round' => $room->current_round,
|
||||
'revealed' => $room->revealed_at !== null,
|
||||
'state_version' => $room->state_version,
|
||||
'statistics' => $pageData->statistics,
|
||||
'deck' => (new RoomDeckResource($room->deck_config))->resolve($request),
|
||||
'players' => $room->players
|
||||
->map(fn ($player) => (new RoomPlayerResource($player, $room))->resolve($request))
|
||||
->all(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user