forge/app/Services/LatestSptVersionService.php
Refringe db578071e4
SPT Semvar & Automatic Resolution
This update gives mod versions a supported SPT version field that accepts a semantic version. The latest supported SPT version will be automatically resolved based on the semvar.

Next up: I need to update the ModVersion to SptVersion relationship to be a many-to-many and expand the resolution to resolve multiple versions.
2024-08-22 17:04:07 -04:00

24 lines
570 B
PHP

<?php
namespace App\Services;
use App\Models\SptVersion;
/**
* This class is responsible for fetching the latest SPT version. It's registered as a singleton in the service
* container so that the latest version is only fetched once per request.
*/
class LatestSptVersionService
{
protected ?SptVersion $version = null;
public function getLatestVersion(): ?SptVersion
{
if ($this->version === null) {
$this->version = SptVersion::select('version')->orderByDesc('version')->first();
}
return $this->version;
}
}