Passing multiple parameters to controller in Laravel 5

后端 未结 4 1391
有刺的猬
有刺的猬 2020-12-10 01:03

In my application, a user has the ability to remind another user about an event invitation. To do that, I need to pass both the IDs of the event, and of the user to be invit

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-10 01:31

    When you define this route:

    Route::get('events/{id}/remind', [
    'as' => 'remindHelper', 'uses' => 'EventsController@remindHelper']);
    

    You are saying that a single URI argument will be passed to the method.

    Try passing the two arguments, like:

    Route::get('events/{event}/remind/{user}', [
    'as' => 'remindHelper', 'uses' => 'EventsController@remindHelper']);
    

    View:

    route('remindHelper',['event'=>$eventId,'user'=>$userId]);
    

提交回复
热议问题