diff --git a/app/Models/Mod.php b/app/Models/Mod.php index 030c7db..84d6e22 100644 --- a/app/Models/Mod.php +++ b/app/Models/Mod.php @@ -14,6 +14,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\SoftDeletes; +use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; use Laravel\Scout\Searchable; @@ -144,6 +145,14 @@ class Mod extends Model return false; } + // Ensure the latest SPT version is within the last three minor versions. + $activeSptVersions = Cache::remember('active-spt-versions', 60 * 60, function () { + return SptVersion::getVersionsForLastThreeMinors(); + }); + if (! in_array($latestVersion->latestSptVersion()->first()->version, $activeSptVersions->pluck('version')->toArray())) { + return false; + } + // All conditions are met; the mod should be searchable. return true; }