build: initialize RetroHub with Laravel, Inertia, Vue, and Horizon
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Features\Games\Data;
|
||||
|
||||
use Spatie\LaravelData\Attributes\MapInputName;
|
||||
use Spatie\LaravelData\Data;
|
||||
use Spatie\LaravelData\Mappers\SnakeCaseMapper;
|
||||
|
||||
#[MapInputName(SnakeCaseMapper::class)]
|
||||
class DashboardStatsData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public int $totalGames,
|
||||
public int $totalConsoles,
|
||||
public int $totalRoms,
|
||||
public int $userSaves,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Features\Games\Data;
|
||||
|
||||
use App\Features\Consoles\Data\ConsoleData;
|
||||
use App\Features\Games\Models\Game;
|
||||
use Spatie\LaravelData\Attributes\MapInputName;
|
||||
use Spatie\LaravelData\Data;
|
||||
use Spatie\LaravelData\Mappers\SnakeCaseMapper;
|
||||
|
||||
#[MapInputName(SnakeCaseMapper::class)]
|
||||
class GameData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public int $id,
|
||||
public int $consoleId,
|
||||
public string $title,
|
||||
public string $slug,
|
||||
public ?int $igdbId,
|
||||
public ?int $tgdbId,
|
||||
public ?string $description,
|
||||
public ?int $releaseYear,
|
||||
public ?string $developer,
|
||||
public ?string $publisher,
|
||||
public ?string $genre,
|
||||
public ?float $rating,
|
||||
public ?string $coverPath,
|
||||
public ?string $thumbnailPath,
|
||||
public ?ConsoleData $console,
|
||||
public ?array $romFiles,
|
||||
) {}
|
||||
|
||||
public static function fromModel(Game $game): self
|
||||
{
|
||||
return new self(
|
||||
id: $game->id,
|
||||
consoleId: $game->console_id,
|
||||
title: $game->title,
|
||||
slug: $game->slug,
|
||||
igdbId: $game->igdb_id,
|
||||
tgdbId: $game->tgdb_id,
|
||||
description: $game->description,
|
||||
releaseYear: $game->release_year,
|
||||
developer: $game->developer,
|
||||
publisher: $game->publisher,
|
||||
genre: $game->genre,
|
||||
rating: $game->rating ? (float) $game->rating : null,
|
||||
coverPath: $game->cover_path,
|
||||
thumbnailPath: $game->thumbnail_path,
|
||||
console: $game->relationLoaded('console') && $game->console
|
||||
? ConsoleData::fromModel($game->console)
|
||||
: null,
|
||||
romFiles: $game->relationLoaded('romFiles')
|
||||
? $game->romFiles->map(fn ($rom) => RomFileData::fromModel($rom))->toArray()
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Features\Games\Data;
|
||||
|
||||
use App\Features\Games\Models\RomFile;
|
||||
use Spatie\LaravelData\Attributes\MapInputName;
|
||||
use Spatie\LaravelData\Data;
|
||||
use Spatie\LaravelData\Mappers\SnakeCaseMapper;
|
||||
|
||||
#[MapInputName(SnakeCaseMapper::class)]
|
||||
class RomFileData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public int $id,
|
||||
public int $gameId,
|
||||
public string $filePath,
|
||||
public string $fileName,
|
||||
public int $fileSize,
|
||||
public string $fileHash,
|
||||
public ?string $region,
|
||||
public ?string $language,
|
||||
) {}
|
||||
|
||||
public static function fromModel(RomFile $romFile): self
|
||||
{
|
||||
return new self(
|
||||
id: $romFile->id,
|
||||
gameId: $romFile->game_id,
|
||||
filePath: $romFile->file_path,
|
||||
fileName: $romFile->file_name,
|
||||
fileSize: $romFile->file_size,
|
||||
fileHash: $romFile->file_hash,
|
||||
region: $romFile->region,
|
||||
language: $romFile->language,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user