Abhishek Shah
Abhishek Shah

Reputation: 145

Laravel Routing a resourceful controller with parameter

I have been using Resourceful controllers due to its simplicity. like so.

route('branches.create')

But my current business need requires i pass a specific parameter.

current/{company}/branches

how can I create a route to fit that kind of url. I have tried route('current.branches.create') and route('current.' . $id . 'branches.create')

Upvotes: 0

Views: 104

Answers (1)

Sreejith BS
Sreejith BS

Reputation: 1203

Keep the route as named routes like:

Route::POST('current/{company}/branches', 'SomeController@somemethod')->name('branches.create');

and pass URL like:

<a href="{{route('branches.create', $company->id)}}">GOT TO URL</a>

More about Larvel Named Routes

Hope it's helpful.

Upvotes: 1

Related Questions