1
votes

I know there are solutions but none of them working for me. Here is my hyperlink

<a href="{{route('voting',$parameters = array('id' =>$answers->id,'votes' =>"1"))}}"><span class="glyphicon glyphicon-chevron-up"></span></a>

This is my route First i tried this one

 Route::get('voting','AnswerController@voting')->name("voting");

then this one

Route::get('voting',array('as'=>'voting','uses'=>'AnswerController@voting'));

My Controller

public function voting($id,$votes){
        //rest  of code 
}

problem i am facing

"Too few arguments to function App\Http\Controllers\AnswerController::voting(), 0 passed and exactly 2 expected"

2

2 Answers

2
votes

I believe you need to give the route 2 parameters

Route::get('voting/{id}/{votes}', array('as'=>'voting','uses'=>'AnswerController@voting'));

Refer to this thread

Passing multiple parameters to controller in Laravel 5

0
votes

Use this

<a href="{{ route('voting',['id' => $answers->id, 'votes' => 1]) }}"><span class="glyphicon glyphicon-chevron-up"></span></a>

Instead of

<a href="{{route('voting',$parameters = array('id' =>$answers->id,'votes' =>"1"))}}"><span class="glyphicon glyphicon-chevron-up"></span></a>