I am beginner of laravel 5.3 Now i am trying to edit user details

My routes:

 Route::get('/Edit/{id}','RegistrationController@Edit');

View

 <td>
         {{ Html::link('/Edit', 'Edit', array('id' => $user->id,'class' =>'btn btn-info'), true)}} 
        </td>

Controller:

public function Edit($id)
    {
        echo $id;
    }

When i click Edit button i get an error like 'NotFoundHttpException in RouteCollection.php line 161:'. What is wrong with me?Please help me

1

There are 1 answers

6
Rohit shah On

Your Error is that you are not passing id withedit route...

you have to do something like /Edit/{id}....

To do so one of the way is to use named route.

Since you are not passing the wild card i.e. $id in the link you are getting this error

In Route File Can you please Change to

Route::get('/Edit/{id}',['as'=>'EditUser','uses'=>'RegistrationController@Edit']);

And in View Change the Link to

{{ Html::link("route('EditUser',[$user->id])", 'Edit', array('id' => $user->id,'class' =>'btn btn-info'), true)}} 

Hope this helps you. Ask if any doubt