diff --git a/app/Http/Controllers/ModController.php b/app/Http/Controllers/ModController.php index 40bfb0a..a4b8404 100644 --- a/app/Http/Controllers/ModController.php +++ b/app/Http/Controllers/ModController.php @@ -6,6 +6,7 @@ use App\Http\Requests\ModRequest; use App\Http\Resources\ModResource; use App\Models\Mod; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; +use Illuminate\Support\Facades\Log; class ModController extends Controller { @@ -29,7 +30,12 @@ class ModController extends Controller { $mod = Mod::select() ->withTotalDownloads() - ->with(['latestSptVersion', 'users:id,name']) + ->with([ + 'versions', + 'latestSptVersion', + 'users:id,name', + 'license:id,name,link' + ]) ->with('license:id,name,link') ->find($modId); diff --git a/app/Models/Mod.php b/app/Models/Mod.php index b44c52b..ce9001c 100644 --- a/app/Models/Mod.php +++ b/app/Models/Mod.php @@ -43,7 +43,7 @@ class Mod extends Model public function versions(): HasMany { - return $this->hasMany(ModVersion::class); + return $this->hasMany(ModVersion::class)->orderByDesc('version'); } /** diff --git a/database/factories/ModVersionFactory.php b/database/factories/ModVersionFactory.php index 513676f..cb8b613 100644 --- a/database/factories/ModVersionFactory.php +++ b/database/factories/ModVersionFactory.php @@ -23,8 +23,8 @@ class ModVersionFactory extends Factory 'virus_total_link' => fake()->url(), 'downloads' => fake()->randomNumber(), 'disabled' => fake()->boolean(), - 'created_at' => Carbon::now(), - 'updated_at' => Carbon::now(), + 'created_at' => Carbon::now()->subDays(rand(0, 365))->subHours(rand(0, 23)), + 'updated_at' => Carbon::now()->subDays(rand(0, 365))->subHours(rand(0, 23)), ]; } } diff --git a/resources/views/mod/show.blade.php b/resources/views/mod/show.blade.php index 3d8012a..46cdc25 100644 --- a/resources/views/mod/show.blade.php +++ b/resources/views/mod/show.blade.php @@ -8,6 +8,8 @@
+ + {{-- mod info card --}}
@@ -19,57 +21,124 @@ @endif
-

- {{ $mod->name }} - - {{ $mod->latestSptVersion->version }} +
+

+ {{ $mod->name }} + + {{ $mod->latestSptVersion->version }} + +

+ + {{ $mod->latestSptVersion->sptVersion->version }} -

+

{{ __('Created by') }} {{ $mod->users->pluck('name')->implode(', ') }}

{{ $mod->latestSptVersion->sptVersion->version }} {{ __('Compatible') }}

-

{{ $mod->total_downloads }} {{ __('Downloads') }}

+

{{ Number::format($mod->total_downloads) }} {{ __('Downloads') }}

-
-
- - {{-- Use an "onChange" listener to redirect the user to the selected tab URL. --}} - -
- -
-
- {{-- The description below is safe to write directly because it has been run though HTMLPurifier during the import process. --}} -

{!! Str::markdown($mod->description) !!}

+ {{-- tabs --}} +
+
+ + {{-- dropdown select, for small screens --}} +
+ + +
+ + {{-- tab buttons --}} + +
+ + {{-- tab panels --}} + {{-- description --}} +
+ {{-- The description below is safe to write directly because it has been run though HTMLPurifier during the import process. --}} +

{!! Str::markdown($mod->description) !!}

+
+ {{-- versions --}} +
+ @foreach($mod->versions as $version) + @if(!$version->disabled) +
+
+
+
+ + Version {{$version->version}} + +

{{ Number::forhumans($version->downloads) }} Downloads

+
+
+ + {{ $version->sptVersion->version }} + + {{__('Virus Total Results')}} +
+
+ Created {{ \Carbon\Carbon::parse($version->created_at)->format("M d, h:m a") }} + Last Updated {{ \Carbon\Carbon::parse($version->updated_at)->format("M d, h:m a") }} +
+
+
+
+

{{$version->description}}

+
+
+ @endif + @endforeach +
+ {{-- Comments --}} +
+

The comments go here

+
+ {{-- right side panel area --}}
+ + {{-- main download button --}} - + + {{-- mod details --}}

{{ __('Details') }}