Its simple just create route with param in url.
// routes.php
Route::get("/user/{id}", array("uses" => "UserController@show", "as" => "user.show");
// UserController.php
class UserController extends BaseController {
public function show($id)
{
echo "User id: ".$id;
}
}
// Usage
URL::route("user.show", array(1)); // generate link to web.com/user/1
Pretty nice indeed, and it also works well with 2 params (like /user/{firstname}/{lastname})
Now just need to work out how I can make it play with my rest-routing :(
Well, turns out to be much more easy than I thought, so my route looks like this:
Route::controller('tool/sitereport', 'SiteReportController');
tool/sitereport/report/param1/param2 would hand over to the getReport function with the two segments as parameters, so
public function getReport($param1, $param2)
{
return $param1 . ', ' . $param2;
}
just works like a charm!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community