Reputation:
I have the following href function in my view and I have to attach a id ($group) to my route.
<a class="btn btn-primary btn-block" href="{{ route('show.invitation', {{$group}}) }}">Invite User to Group</a>
This is my web route.
Route::get('invitation/show{group}', 'InvitationController@show')->name('show.invitation');
I get this error message.
Missing required parameters for [Route: show.invitation] [URI: invitation/show/{group}]. (View: /Users/daniel/Documents/Development/Laravel/bolzer/resources/views/settinggroup/overview.blade.php)
Upvotes: 0
Views: 8076
Reputation: 804
first, edit your route
Route::get('invitation/show/{group}', 'InvitationController@show')->name('show.invitation');
with route() method, pass the name of the route
<a href="{{ route('show.invitation', $group) }}" class="btn btn-primary">Invite User to Group</a>
with url() method, pass URL of the route
<a href="{{ url('/invitation/show/', $group) }}" class="btn btn-primary">Invite User to Group</a>
Upvotes: 1
Reputation: 91
If you use a key'd array() you can also define the specific elements within each URL, e.g:
<a href=" {{ route('some.example', ['group'=>$group, 'somename'=>...]) }}">Link</a>
Upvotes: 0
Reputation: 4499
simply pass the $group
NOT the {{$group}}
to the route()
functions second parameter.
<a class="btn btn-primary btn-block"
href="{{ route('show.invitation', $group) }}">
Invite User to Group
</a>
Upvotes: 0
Reputation: 2416
Group variable should be concatenated with route()
's first parameter. Simply use .
where you use ,
href="{{ route('show.invitation'.{{$group}}) }}"
But the best practice is what @Sunil_kumawat say.
Upvotes: 0