'How to route with id in URL

I want to route with the URL accept_form/1 which I get after clicking an anchor tag.

What should I write in my Route?

I am trying this:

Route::get('accept_form/{$id}', 'Controller@accept_form');

View :

<a href="{{ url('accept_form/' . $key->id) }}" class="small-box-footer">
   More info <i class="fa fa-arrow-circle-right"></i>
</a>


Solution 1:[1]

Give a specific name of your routes like below.

Route::get('/accept_form/{id}', 'YourController@yourMethod')->name('accept_form');

Then pass parameters with array along with route function,

<a href="{{ route('accept_form', [$id])}}"> More info</a> 

Solution 2:[2]

Named your route,

Route::get('/accept_form/{id}', 'YourController@yourMethod')->name('accept_form');

Then You can use,

<a href="{{ route('accept_form', $id)}}"> More info</a> 

Solution 3:[3]

you can do like this

{{ route('accept_form', ['id'=>$id])}}

Solution 4:[4]

Change Route to

Route::get('accept_form/{id}', 'Controller@accept_form');

Anchor tag

<a href="{{ url('accept_form', $id)}}" class="small-box-footer"> More Indo </a>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 narayansharma91
Solution 2
Solution 3 Adnan Rasheed
Solution 4 raihan