在具有多个参数的路径上缺少必需的参数错误

时间:2018-04-27 08:22:53

标签: laravel-5

此错误消息一直显示

Missing required parameters for [Route: merchants.add.channel] [URI: merchants/{key}/denomination/{keydenom}/channel/addChannel].

这是我的路线

Route::get('merchants/{key}/denomination/{keydenom}/channel', 'MerchantsController@channel')->name('merchants.channel');

这是我的功能

public function channel($id)
{
  if (!can('merchants_list_channel')) {
      return redirect()->route('home');
  }
  $merchant = MerchantDenomination::where('id', $id)->pluck('name')->first();
  $statusDenomList = [
      '' => '-- All --',
      'ACTIVE' => 'Active',
      'DISABLE' => 'Disable',
      'OFS' => 'OFS'
  ];
    return view('merchants.channel', compact('statusDenomList', 'id', 'merchant'));
}

1 个答案:

答案 0 :(得分:0)

该路线有2个路线参数:{key}和{keydenom}。

您的控制器功能应该同时满足它们:

public function channel($key, $keydom) {
  // Do your job
}

每次拨打route()时,您还需要表达参数:

 route('merchants.channel', ['key' => "your-key", 'keydom' => "your-keydom"])