Php 传递的函数App\Http\Controllers 0的参数太少,需要正好2个";

Php 传递的函数App\Http\Controllers 0的参数太少,需要正好2个";,php,laravel,Php,Laravel,我知道有解决办法,但没有一个对我有效。 这是我的超链接 <a href="{{route('voting',$parameters = array('id' =>$answers->id,'votes' =>"1"))}}"><span class="glyphicon glyphicon-chevron-up"></span></a> <a href="{{route('voting',$parameters = arr

我知道有解决办法,但没有一个对我有效。 这是我的超链接

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

Route::get('voting',array('as'=>'voting','uses'=>'AnswerController@voting'));
我的控制器

public function voting($id,$votes){
        //rest  of code 
}
我面临的问题

“参数太少,无法正常工作 App\Http\Controllers\AnswerController::voting(),0已通过,且准确无误 2预期“


我相信你需要给出路线2的参数

Route::get('voting/{id}/{votes}', array('as'=>'voting','uses'=>'AnswerController@voting'));
请参阅此线程

使用这个

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

而不是


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