Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: migrate the Random Set route to a controller method #2665

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions app/Platform/Controllers/GameController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Http\Controller;
use App\Models\Game;
use App\Models\System;
use App\Platform\Requests\GameRequest;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
Expand Down Expand Up @@ -106,4 +107,16 @@ public function destroy(Game $game): void
{
$this->authorize('delete', $game);
}

public function random(): RedirectResponse
{
$this->authorize('viewAny', Game::class);

$randomGameWithAchievements = Game::whereNotIn('ConsoleID', System::getNonGameSystems())
->where('achievements_published', '>=', 6)
->inRandomOrder()
->firstOrFail();

return redirect(route('game.show', ['game' => $randomGameWithAchievements]));
}
}
2 changes: 2 additions & 0 deletions app/Platform/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Models\GameHash;
use App\Platform\Controllers\AchievementController;
use App\Platform\Controllers\GameController;
use App\Platform\Controllers\GameHashController;
use App\Platform\Controllers\PlayerAchievementController;
use App\Platform\Controllers\PlayerGameController;
Expand Down Expand Up @@ -63,6 +64,7 @@ protected function mapWebRoutes(): void
// Route::get('game/{game}/badges', [GameBadgeController::class, 'index'])->name('game.badge.index');
// Route::get('game/{game}/assets', [GameAssetsController::class, 'index'])->name('game.asset.index');
// Route::get('game/{game}/players', [GamePlayerController::class, 'index'])->name('game.player.index');
Route::get('game/random', [GameController::class, 'random'])->name('game.random');

// Route::get('create', CreateController::class)->name('create');
// Route::resource('developers', DeveloperController::class)->only('index');
Expand Down
23 changes: 0 additions & 23 deletions resources/views/pages/game/random.blade.php

This file was deleted.

Loading