Reputation: 5355
I am using Laravel 5.4 and I have created a controller with resources. Now I would like to open the edit page in my app like the following:
a href="{{ route('tasks.edit', ['tasks'=>$storedTask->id]) }}" class='btn btn-default'>Edit</a>
In my view I am using:
Route::resource('/', 'IndexController');
However, I get back
Sorry, the page you are looking for could not be found when opening the link.
When looking into my routes list the URIs are emtpy.
+--------+-----------+------------------------+------------------+------------------------------------------------------------------------+--------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+-----------+------------------------+------------------+------------------------------------------------------------------------+--------------+
| | GET|HEAD | / | index | App\Http\Controllers\IndexController@index | web |
| | POST | / | store | App\Http\Controllers\IndexController@store | web |
| | PUT|PATCH | {} | update | App\Http\Controllers\IndexController@update | web |
| | DELETE | {} | destroy | App\Http\Controllers\IndexController@destroy | web |
| | GET|HEAD | {} | show | App\Http\Controllers\IndexController@show | web |
| | GET|HEAD | {}/edit | edit | App\Http\Controllers\IndexController@edit | web |
+--------+-----------+------------------------+------------------+------------------------------------------------------------------------+--------------+
I guess that my model is not "associated" with my controller and therefore the Route::resource
view.
Any suggestions how to fix this?
Upvotes: 1
Views: 98
Reputation: 163798
You can't use resource route with just /
. Change it to:
Route::resource('tasks', 'IndexController');
Upvotes: 2