Created
July 16, 2017 07:57
-
-
Save Cleanse/d3bad80d9b253ee7b42c10692a06b5c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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