Dmitriy Skogorev
Dmitriy Skogorev

Reputation: 189

How to build path to route in Laravel with parameter?

I have this route

Route::get('org/edit/{id}/', ['as' => 'org.edit', 'uses' => 'OrgController@edit']);

And then create a link to this route by using Laravel Blade template:

<a href="{{ route('org.edit', [$org->id]) }}" class="btn btn-primary"><span class="glyphicon glyphicon-edit"></span></a>

What I expect to see:

/org/edit/123/

What I get:

/org/edit?123

What am I doing wrong?

Upvotes: 0

Views: 729

Answers (2)

Patryk Woziński
Patryk Woziński

Reputation: 746

Dmitriy, in this case you can try two ways.

{{ route('org.edit', ['id' => $org->id,]) }}

{{ route('org.edit', $org->id) }}

Check this out. :)

Upvotes: 1

user1669496
user1669496

Reputation: 33148

Try passing it as a key value pair.

{{ route('org.edit', ['id' => $org->id]) }}

Upvotes: 2

Related Questions