Silly me, I forgot about putting them in an array;
<a href="{{ URL::route('lists.items.edit', $userlist->id, $useritem->id) }}">
SHOULD BE
<a href="{{ URL::route('lists.items.edit', array($userlist->id, $useritem->id)) }}">
質問
I have updated my routes restfully as below;
Route::resource('lists', 'UserlistsController');
Route::resource('lists.items', 'UseritemsController');
I can see my routes in PHP Artisan Routes below (Broken up for easier reading);
GET|HEAD lists/{lists}/items/{items}/edit |
lists.items.edit |
UseritemsController@edit
I want to be able to get to these routes but am unsure what I need to pass and how.
For example on a page displaying the users items WITHIN a list for example the URL may be domain.com/lists/2 I want to click a button on the item to destroy or edit it.
In my view I have the following code when going through a foreach loop...
<a href="{{ URL::route('lists.items.edit', $userlist->id, $useritem->id) }}">
Clicking this route simply takes me to domain.com/lists/2/items//edit and the code breaks. How can I get my items to redirect properly to the correct route.
Many thanks in advance.
解決
Silly me, I forgot about putting them in an array;
<a href="{{ URL::route('lists.items.edit', $userlist->id, $useritem->id) }}">
SHOULD BE
<a href="{{ URL::route('lists.items.edit', array($userlist->id, $useritem->id)) }}">