I was trying to access "UserController@edit" but it doesn't found, what did i do wrong?

This is my link

<a href="{{ url($i->id.'/edit') }}">edit</a>

This is my web.php

Route::resource('/', UserController::class);

When i run php artisan route:list this is the return

GET|HEAD | {}/edit | edit | App\Http\Controllers\UserController@edit | web

>Solution :

It should be

<a href="{{ route('user.edit', $i->id) }}">edit</a>

and

Route::resource('user', UserController::class);

The first argument of the resource should be the name of the route group and not the route.

Leave a Reply