Reputation: 115
im trying to create a route to a controller action with a specific parameter. So this is what ive got so far:
Route::get('faq', array("as"=>"faq","uses"=>"SiteController@showPage"));
What i want is something like
Route::get('faq', array("as"=>"faq","uses"=>"SiteController@showPage","params"=>"faq"));
The corresponding controller action looks like that
public function showPage($type) {
$page = Page::where("type", "=", $type)->first();
return View::make("pages.page")
->with("title", $page->title)
->with("page", $page);
}
The pages are saved in the database, so im trying to use only one function for that und call it with different params.
Any ideas? And i dont want to resolve it like that
Route::get('page/{type}', array("as"=>"faq","uses"=>"SiteController@showPage"));
Because otherwise the urls will look like /page/agb.
Thanks in advance.
Upvotes: 0
Views: 1582
Reputation: 36
I think what you're after is this:
Route::get("/{type}", array("as" => "showPage", "uses" => "SiteController@showPage"));
... just make sure to define that route after other more specific routes that you dont want handled by SiteController@showPage.
Upvotes: 1