Reputation: 2379
I want to pass current agency id from route to controller in laravel 5.2.
ex:- I have one resource controller is AgencyController.
Route::resource('agencies', 'Admin\AgencyController');
I want to add one more route, such as,
Route::get('agencies/me', 'Admin\AgencyController@show', ['middleware' => ['web', 'agency']]);
Here I want to pass agency id from session as default parameter to agencyController@show
function.
ex:- Auth::guard('agency')->user()->agencies_id
Is it possible in laravel?
Upvotes: 0
Views: 2032
Reputation: 4783
Laravel routes function that if you configure your route like:
Route::get('user/{user}', 'UserController@someMethod');
you can pick up whatever you send after the slash in the controller. So if you call:
www.example.com/user/3
and your controller is like public function someMethod($id)
the 3 will be forwarded to $id
variable
Upvotes: 1