how to pass variable in route name in laravel?

I have defined route

Route::get('/edit-industry/{id}', '[email protected]')->name('admin.editIndustry');

And passing variable by

{{ route('admin.editIndustry', ['id'=>1]) }}


{{ route('admin.editIndustry', [1]) }}

This is not working. How to pass variable here?

If you have only one parameter you can do that :

{{ route('admin.editIndustry', 1) }}

You can Directly pass with route name

{{ URL::to('/edit-industry/1') }}

Simply try like this




Route::get('/edit-industry/{id}', '[email protected]')


public function edit($id){
    // use $id here

Hope you understand.

Using generating URLs from Named Routes route():

{{ route('admin.editIndustry', 1) }}

Using URLs url():

{{url('/edit-industry', [1])}}

wow, why are wrong answers (or answers for questions which were not asked in this case) upvoted?

EkinOf is correct, you can do

{{ route('admin.editIndustry', 1) }}

Btw your first one works too and is necessary, if you have more than 1 parameter

{{ route('admin.editIndustry', ['id'=>1]) }}
{{ route('admin.editIndustry', ['id'=>1, 'something'=>42]) }}