stackoverflow account
stackoverflow account

Reputation: 235

Laravel : Pass dynamic variables to routes

New to Laravel so please be patient with me, I have a route in web.php as below :

Route::get('/add_rcord/{formid}/{userid}', 'site_controller@add_rcord')->name('add_rcord');

I need to go to the URL by clicking a link while passing 2 variables as below :

<?php

  $value1=1;
  $value2=2; ?>
  <a href="{{route('/add_rcord/$value1/$value2')}}">Add Record</a>

This does not work , Can someone advise me how can I do that

Upvotes: 2

Views: 2758

Answers (1)

STA
STA

Reputation: 34688

Define the parameter name, if you have multiple parameter :

route('add_rcord', ['formid' => $value1, 'userid' => $value2])

Upvotes: 6

Related Questions