Support the ongoing development of Laravel.io →
Requests Input
Last updated 2 years ago.
0
Solution

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
Last updated 2 years ago.
0

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 :(

Last updated 2 years ago.
0

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!

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.