mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-12 20:20:41 -05:00
display filtered spt version
This commit is contained in:
parent
5dade5dfcf
commit
cc3cdddce3
@ -16,7 +16,7 @@ class ModIndex extends Component
|
||||
|
||||
public string $sectionFilter = 'featured';
|
||||
|
||||
public string $versionFilter = '';
|
||||
public int $versionFilter = -1;
|
||||
|
||||
public function render()
|
||||
{
|
||||
@ -41,14 +41,23 @@ class ModIndex extends Component
|
||||
|
||||
$mods = Mod::select(['id', 'name', 'slug', 'teaser', 'thumbnail', 'featured', 'created_at'])
|
||||
->withTotalDownloads()
|
||||
->with(['latestVersion', 'latestVersion.sptVersion', 'users:id,name'])
|
||||
->whereHas('latestVersion')
|
||||
->with(['users:id,name'])
|
||||
->where('name', 'like', '%'.Str::trim($this->modSearch).'%');
|
||||
|
||||
if ($this->versionFilter === -1) {
|
||||
$mods = $mods
|
||||
->with(['latestVersion', 'latestVersion.sptVersion'])
|
||||
->whereHas('latestVersion.sptVersion');
|
||||
} else {
|
||||
$mods = $mods->with(['latestVersion' => function ($query) {
|
||||
$query->where('spt_version_id', $this->versionFilter);
|
||||
}, 'latestVersion.sptVersion'])
|
||||
->whereHas('latestVersion.sptVersion', function ($query) {
|
||||
$query->where('version', 'like', '%'.Str::trim($this->versionFilter).'%');
|
||||
})
|
||||
->where('name', 'like', '%'.Str::trim($this->modSearch).'%')
|
||||
->orderByDesc($section)
|
||||
->paginate(12);
|
||||
$query->where('spt_version_id', $this->versionFilter);
|
||||
});
|
||||
}
|
||||
|
||||
$mods = $mods->orderByDesc($section)->paginate(12);
|
||||
|
||||
$sptVersions = SptVersion::select(['id', 'version', 'color_class'])->orderByDesc('version')->get();
|
||||
|
||||
|
@ -69,9 +69,9 @@
|
||||
<div class="flex flex-col text-gray-700 bg-gray-300 dark:text-gray-200 dark:bg-gray-950 p-4 rounded-xl">
|
||||
<h2>SPT Version</h2>
|
||||
<select wire:model.live="versionFilter" class="rounded-md dark:text-white bg-gray-100 dark:bg-gray-950 border-gray-300 dark:border-gray-700 focus:border-grey-500 dark:focus:border-grey-600 focus:ring-grey-500 dark:focus:ring-grey-600">
|
||||
<option disabled value="">Select a version</option>
|
||||
<option disabled value="-1">Select a version</option>
|
||||
@foreach($sptVersions as $version)
|
||||
<option value="{{ $version->version }}">{{ $version->version }}</option>
|
||||
<option value="{{ $version->id }}">{{ $version->version }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user