Passing A Parameter To A Route And Controller In Laravel 6

- 1 answer

I am quite new in Laravel so please help. I am trying to pass a parameter from a blade file to a route which then passes the parameter to the controller. This is a resource controller. I've tried the URL() way of calling, I've tried making the route callback function do the same thing but for some reason, the ID was never passed to the function but it appears in my address bar. So it never got to the dd($id) part of the code. I also tried creating a new model and controller just for this but it also did not seem to work.

What am I missing here?

This is my view code:

<td><a target="_blank" rel="nofollow noreferrer" href="{{ route('/cars/'. $car->id)}}" class="btn btn-primary">Rent</a></td>

This is my route: Route::get('cars/{id}', '[email protected]');

This is the controller code:

public function updateUserId($id)
    $user_id = Auth::id();


Just use this {{ route('/cars/', $car->id) }} OR {{ route('cars', $car->id) }} and don't concatenate this as a string because route method accept a second parameter for this case.