Reputation: 1235
How to achive this route :
/test /test/page-2
I want to pass "2" as parameter and if we are in page 1 just show /test not /test/page
Upvotes: 0
Views: 54
Reputation: 3026
I agree with the above comment, why not just use the page number alone as a parameter?
Routes:
Route::get('test', ['uses' => 'TestController@index']);
Route::get('test/page/{pageNumber?}', ['uses' => 'TestController@index']);
TestController method:
Assuming your views are in a directory tests
and are named testPage-1
, testPage-2
, testPage-3
, etc...
public function index($pageNumber = 1){
return View::make('tests.testPage-'.$pageNumber);
}
Upvotes: 1