Skip to content

Instantly share code, notes, and snippets.

@Cleanse
Created July 16, 2017 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cleanse/d3bad80d9b253ee7b42c10692a06b5c6 to your computer and use it in GitHub Desktop.
Save Cleanse/d3bad80d9b253ee7b42c10692a06b5c6 to your computer and use it in GitHub Desktop.
<?php namespace Cleanse\League;
use Redirect;
use Route;
use Cleanse\League\Models\Tournament;
Route::get('tournament/{id}/{slug?}', function ($tourneyId, $tourneySlug = null) {
$tournament = Tournament::where('id', $tourneyId)->first();
if (!$tournament) {
$notFound = '/404';
return Redirect::to($notFound);
}
if (is_null($tourneySlug)) {
$url = '/tournament/' . $tournament->id . '/' . $tournament->slug;
return Redirect::to($url, 301);
}
if ($tourneySlug !== $tournament->slug) {
$url = '/tournament/' . $tournament->id . '/' . $tournament->slug;
return Redirect::to($url, 301);
}
return view('cleanse.league::bracket', ['tournament' => $tournament]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment