0

I have a link

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

Route

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

controller

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

But when i echo $id it always shows $user->s_no(static) as value.I want to get id as 1,2,3 etc.What is wrong with me?I don't know i am doing right way or not.Please help me?

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

2 Answers2

1

Try this :

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

or

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

and if you setting id dynamically then you should get that value in variable first and then concatenate it with id like:

 {{ Html::link('/Edit/id', 'Edit', array('id' => "your variable" ,'class' =>'btn btn-info'), true)}} 
Anurag_Soni
  • 542
  • 2
  • 17
  • if i use {{ Html::link('/Edit/id', 'Edit', array('id' => 1,'class' =>'btn btn-info'), true)}} i get id as simply id means i dint get 1,2,3 – Shanu k k Dec 26 '16 at 10:43
  • try this {{ Html::link('/Edit/id=1', 'Edit', array('id' => 1,'class' =>'btn btn-info'), true)}} – Anurag_Soni Dec 26 '16 at 12:24
  • this is working fine..but instead of id=1 i want to set my variable here but how? – Shanu k k Dec 26 '16 at 12:27
  • Now you can concatenate you variable instead of 1 in above code like :{{ Html::link('/Edit/id='+$user->s_no, 'Edit', array('id' => 1,'class' =>'btn btn-info'), true)}} – Anurag_Soni Dec 26 '16 at 12:29
  • i dont know i am beginner in laravel.Please help me – Shanu k k Dec 26 '16 at 12:30
  • @Anurag_Systematix- Thanks a lot.it's working but its didint show function edit in url now browser url seems https://localhost/laravel_demo/public/1 but i need https://localhost/laravel_demo/public/edit/1 – Shanu k k Dec 26 '16 at 12:33
  • @Shanu k k please mark solution as answer so that it can help other – Anurag_Soni Dec 26 '16 at 12:39
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/131509/discussion-between-shanu-k-k-and-anurag-systematix). – Shanu k k Dec 26 '16 at 12:48
0

Please check this link for more detail link enter link description here

If the controller action method takes arguments, you can specify them in the third parameter, as a simple array.

{{ HTML::linkAction('ItemController@show', 'Show Item #3', array(3)) }}

The HTML would look like below (depending on your routes).

<a href="http://your.url/items/3">Show Item #3</a>

enter image description here

Anurag_Soni
  • 542
  • 2
  • 17