2024-05-17 23:54:03 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\View\Components;
|
|
|
|
|
|
|
|
use App\Models\Mod;
|
|
|
|
use Illuminate\Contracts\View\View;
|
|
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
|
|
use Illuminate\View\Component;
|
|
|
|
|
|
|
|
class ModListSection extends Component
|
|
|
|
{
|
2024-05-21 21:02:49 -04:00
|
|
|
public Collection $modsFeatured;
|
2024-05-17 23:54:03 -04:00
|
|
|
public Collection $modsLatest;
|
|
|
|
public Collection $modsUpdated;
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
2024-05-21 21:02:49 -04:00
|
|
|
$this->modsFeatured = $this->fetchFeaturedMods();
|
2024-05-17 23:54:03 -04:00
|
|
|
$this->modsLatest = $this->fetchLatestMods();
|
|
|
|
$this->modsUpdated = $this->fetchUpdatedMods();
|
|
|
|
}
|
|
|
|
|
2024-05-21 21:02:49 -04:00
|
|
|
private function fetchFeaturedMods(): Collection
|
2024-05-17 23:54:03 -04:00
|
|
|
{
|
2024-05-21 21:02:49 -04:00
|
|
|
return Mod::with('versionLatestSptVersion.sptVersion')->whereFeatured(true)->take(6)->get();
|
2024-05-17 23:54:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
private function fetchLatestMods(): Collection
|
|
|
|
{
|
|
|
|
return Mod::with('versionLatestSptVersion.sptVersion')->latest()->take(6)->get();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function fetchUpdatedMods(): Collection
|
|
|
|
{
|
|
|
|
return Mod::with('versionLastUpdated.sptVersion')->take(6)->get();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSections(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
[
|
2024-05-21 21:02:49 -04:00
|
|
|
'title' => 'Featured Mods',
|
|
|
|
'mods' => $this->modsFeatured,
|
2024-05-17 23:54:03 -04:00
|
|
|
'versionScope' => 'versionLatestSptVersion'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'title' => 'Latest Mods',
|
|
|
|
'mods' => $this->modsLatest,
|
|
|
|
'versionScope' => 'versionLatestSptVersion'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'title' => 'Recently Updated Mods',
|
|
|
|
'mods' => $this->modsUpdated,
|
|
|
|
'versionScope' => 'versionLastUpdated'
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render(): View
|
|
|
|
{
|
|
|
|
return view('components.mod-list-section', [
|
|
|
|
'sections' => $this->getSections(),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|