laravel - html::link to dynamic route -


i trying output list of users on blade.php page. clicking on user's id should take individual profile page.

here view browse.blade.php file

<?php $cars = db::table('cars')->get(); foreach ($cars $car) {      echo "<table >" ;      echo "<tr>";      html::linkroute('browse/'.$car->car_id, 'car id: '.$car->car_id);      echo "<td>make: $car->make <br/ ></td>" ;      echo "</tr>";      echo "</table>"; } ?> 

my controller

public function browse() {     return view::make('car/browse'); }  public function showprofile($car_id) {     return view::make('car/profile')->with('car_id', $car_id); } 

my route

route::any('browse/{car_id}', 'browsecontroller@showprofile'); 

i want view page output bunch of cars in database. clicking on car car_id = should tak me http://localhost:8000/browse/i each respectic car_id.

am taking wrong approach html::linkroute?

typing http://localhost:8000/browse/i browser works i. therefore, route , showprofile working properly.

however when load browse.blade.php receive following error enter image description here

10018 first car id. why isn't route::any('browse/{car_id}' working?


edit:

thanks msturdy suggestion

changed route::any('browse/{car_id}', 'browsecontroller@showprofile');

to

route::any('browse/{car_id}', [     'as' => 'profile',     'uses' => 'browsecontroller@showprofile']); 

and changed html route

html::linkroute('profile', 'car id: '.$car->car_id, array($car->car_id)); 

the errors gone no link displaying on browse page.

first, update route has 'name' can use elsewhere in application. we'll call 'browse' in example:

route::any('browse/{car_id}', array('as' => 'browse', 'uses' => 'browsecontroller@showprofile')); 

then html::linkroute() takes route name, title of link , parameters separate arguments:

 html::linkroute('browse', "car id: " . $car->car_id, array($car->car_id)); 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -