Mr. Pyramid Mr. Pyramid - 3 years ago 204
PHP Question

how to pass value to controller from view in Laravel

hello folks I'm working on Laravel 5.2 and there I got stuck in a mess.
Actually I want to pass book_id to controller from hyperlink so that whenever use clicks on the link on the basis of book_id controller will return the description of selected book. How to do this?


<a href="{{url('bookdetail/'.$value->book_id)}}" class="title" >{{$value->book_name}}</a><br>


public function viewbook($id)
$book_detail= DB::select('select * from book_master where book_id=?',[$id]);
return view('book_detail',['bookdetail'=>$book_detail]);



Also I want to know who to create route for that hyperlink that will pass the book_id to viewbook method

Answer Source

Oops pity me I only need to add a route into routes.php


Now it's working fine for me!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download