Reputation: 4646
Given the following code, I simple want the second route to send an arbitrary value for id or any other variable I can access from within show()
;
Route::get('foo/{id}', 'FoobarController@show')->where('id', '[0-9]+');
Route::get('bar', 'FoobarController@show')->with('id', -1); // This pseudo-code doesn't work. I want to send parameter id with an arbitrary value
Upvotes: 0
Views: 105
Reputation: 1616
Why not like this?
Routes:
Route::get('bar/{id?}', 'FoobarController@show')->where('id', '[0-9]+');
Controller:
class FoobarController extends Controller{
public function show($id){
$id = $id ? $id : "default value";
}
}
Or:
public function show($id="default value"){..}
Upvotes: 1