How to pass two variables from a view to the controller?

3

I have a link where I already pass a variable to the controller. It works ok. How do I get through two?

My link in View:

<a href="{{url("/ordemvar/$equipam->codigoequipamento")}}"><i class="glyphicon glyphicon-tasks"></i></a>

Would it be something like this?

<a href="{{url("/ordemvar/$equipam->id?$equipam->codigoequipamento")}}"><i class="glyphicon glyphicon-tasks"></i></a>

How do I get the controller

public function pegaEquipa($prm)
{
return $prm;
}

Thanks

    
asked by anonymous 11.01.2017 / 17:41

1 answer

2

You can do it in different ways.

<a href="{ {url("/ordemvar/$equipam->codigoequipamento/$equipam->nome") }}"> Link </a>

See above have two slugs separated by slash.

Then your controller would look like this:

public function pegaEquipa($slug1, $slug2)
{
    echo $slug1;
    echo '<br>';
    echo $slug2;
}

Or QueryString .

<a href="{ {url("/ordemvar?id=$equipam->codigoequipamento&nome=$equipam->nome") }}"> Link </a>

And in the controller it would look like this:

public function pegaEquipa(Request $request)
{
    echo $request->get('id');
    echo '<br>';
    echo $request->get('nome');
}
    
11.01.2017 / 17:53