Laravel 5.5:路由没有捕获/缺少单个参数

时间:2017-12-05 01:00:57

标签: php parameters routes laravel-5.5

看来参数没有通过,但经过各种编辑没有运气,也没办法将其剥离。

错误:

Missing required parameters for [Route: request.new-request] 
[URI: housing-request/{unit}]. 
(View: /vhosts/web.local/resources/views/requests/unit-1.blade.php)

链接/ URL:

<a href="{{ route('request.new-request', ['unit' => 'single']) }}">
http://web.local/housing-request/single

路线:

Route::get('/housing-request/{unit}', 'RequestsController@showHousingUnit')->name('request.new-request');

控制器:

  public function showHousingUnit($unit)
  {

      if($unit == "single"){

         return view('requests.unit-1');

      } else if($unit == "double") {

        return view('requests.unit-2');

     }

  }

2 个答案:

答案 0 :(得分:0)

就这样通过。

<a href="{{ route('request.new-request','single') }}">
http://web.local/housing-request/single </a>

答案 1 :(得分:0)

错误发生在视图中缺少参数

的路径上