You could create a seperate route instead:
Route::get('scopes/{id}', ['as' => 'scopes.index', 'uses' => 'ScopeController@index']);
And exclude it from your resource route:
Route::resource('scopes', 'ScopesController', ['except' => ['index']]);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm using resourceful routing and I need to pass a parameter to the index function of the controller.
public function index($id){ // do something with $id }
If I try to create a form like (say $user->id = 3):
{{ Form::open(array('route' => array('scopes.index', $user->id))) }} {{ Form::close() }}
I get in the html this link: http://alumni.app/scopes?3 which is not good because it doesn't follow the URI for that named route. So, how should I proceed?
Discussion: I'm trying to load a list of scopes depending on the current user. I made an independent scopes controller.
You could create a seperate route instead:
Route::get('scopes/{id}', ['as' => 'scopes.index', 'uses' => 'ScopeController@index']);
And exclude it from your resource route:
Route::resource('scopes', 'ScopesController', ['except' => ['index']]);
Please or to participate in this conversation.