BaHar AyØub
BaHar AyØub

Reputation: 337

Laravel 4-pass mutiple parameters to route

I'm new to Laravel 4, and i need to know how to pass multiple parameters to URL::route

my route:

/*==========================
| edit-adherent (Get)
*///========================
Route::post('/manage-association/{id_association}/edit-adherent/{id_adherent}', array(
'as'    => 'edit-adherent',
'uses'  => 'AdherentController@postEditAdherent'
));

I tried the following syntax but it's not working:

<a href="{{ URL::route('edit-adherent', $id_association, $adherent->id) }}">Edit</a>

I also tried that one:

<a href="{{ URL::route('edit-adherent', array($id_association, $adherent->id)}}">Edit</a>

any help would be greatly appreciated, and sorry for my bad english

Upvotes: 1

Views: 3704

Answers (1)

Quasdunk
Quasdunk

Reputation: 15220

Passing the parameters as an array is actually correct, but there's a bracket ) missing at the end in your code. So this

{{ URL::route('edit-adherent', array($id_association, $adherent->id)) }}

should workd as expected.

If you're not sure about the syntax or the right way/order to pass parameters, don't forget that Laravel is open source, so you can always have a look at the source code for clarification.

If you're using an IDE like Netbeans or PhpStorm (both are absolutely awesome), you should check out Laravel IDE Helper. It will show you what parameters are accepted, and if still in doubt, it will quickly lead you to the method implementation.

Upvotes: 5

Related Questions