The problem that I am having is that if I pass a value of an optional parameter in my get request, I get the same result that I would if no value was passed.
Route:
Route::get('/play/game/{new?}', [
'uses' => 'GameController@getGame',
'as' => 'game'
]);
Controller:
public function getGame($new = null) {
$quotes = Quote::orderBy('created_at', 'dec')->paginate(50);
if(!is_null($new)) {
if ($new == 'yes')
$newgame = true;
} else {
$newgame = false;
}
return view('game', ['quotes' => $quotes, 'newgame' => $newgame]);
}
View:
@if($newgame ==true)
{{Session::flush()}}
@endif
@if($newgame == false)
<h1>Not a new game</h1>
@endif
The second if statement in the view is just a test, and it is this statement that always executes. For reference, I am using Laravel 5.2