Dmitriy Skogorev Dmitriy Skogorev - 7 months ago 33
PHP Question

How to build path to route in laravel with parameter?

I have next route

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


and then create link to this route by laravel blade template:

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


what i expects to see:

/org/edit/123/


what i get:

/org/edit?123


what i'm doing wrong?

Answer Source

Try passing it as a key value pair.

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