mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-13 04:30:41 -05:00
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.
24 lines
570 B
PHP
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;
|
|
}
|
|
}
|