forge/app/Http/Resources/ModVersionResource.php
2025-01-30 20:49:56 -05:00

38 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Resources;
use App\Models\ModVersion;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Override;
/** @mixin ModVersion */
class ModVersionResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
#[Override]
public function toArray(Request $request): array
{
return [
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'published_at' => $this->published_at,
'id' => $this->id,
'version' => $this->version,
'description' => $this->description,
'virus_total_link' => $this->virus_total_link,
'downloads' => $this->downloads,
'mod_id' => $this->mod_id,
'mod' => new ModResource($this->whenLoaded('mod')),
'sptVersion' => new SptVersionResource($this->whenLoaded('sptVersion')),
];
}
}