38 lines
1003 B
PHP
38 lines
1003 B
PHP
<?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,
|
|
);
|
|
}
|
|
}
|