Pass route variable to controller method

Asked

Viewed 931 times

4

I need to pass a variable from a route to a controller method.

The route:

Route::get('busca/{id}', 'MatriculasController@busca');

How can I pass the variable id for the method?

1 answer

4


You use as parameter, slug of his method.

Matriculascontroller.php

public function busca($id){

    dd($id);

}
  • 1

    Thank you very much!

  • 1

    You are welcome! You are using the variable as slug. But if you use as a parameter in URL, p.e busca?id={$id}, you put in the method Input::get('id').

Browser other questions tagged

You are not signed in. Login or sign up in order to post.