0

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

Shanu k k
  • 1,235
  • 2
  • 18
  • 43

1 Answers1

1

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

Rohit shah
  • 833
  • 4
  • 15
  • -thanks but i get an error Parse error: syntax error, unexpected 'EditUser' (T_STRING), expecting ',' or ')' (View: C:\xampp\htdocs\laravel_demo\resources\views\pages\viewdetails.blade.php) – Shanu k k Dec 26 '16 at 06:54
  • might be because of some quote or brackets are missing..you can also do like your previous Html::link just by giving the id {{ Html::link('/Edit/$user->id', 'Edit', array('id' => $user->id,'class' =>'btn btn-info'), true)}} – Rohit shah Dec 26 '16 at 06:55
  • -get an error Undefined property: stdClass::$id (View: C:\xampp\htdocs\laravel_demo\resources\views\pages\viewdetails.blade.php) what is wrong? – Shanu k k Dec 26 '16 at 07:23
  • -localhost/laravel_demo/public/Edit/$user->s_no url i need 1,2,3 instead of $user->s_no :-( – Shanu k k Dec 26 '16 at 07:28
  • sorry but i m not able to get what are you saying – Rohit shah Dec 26 '16 at 07:43
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/131482/discussion-between-rohit-shah-and-shanu-k-k). – Rohit shah Dec 26 '16 at 08:00