2016-07-12 47 views
0

請確認下面的步驟是正確的(特別返回重定向()部分)缺少參數使用retrun重定向 - Laravel

路線「Dashboard2」期待2個變量如下打開控制板查看通過getDashboard功能:

Route::get('/dashboard2/{wordsRowB}/{wordsRowId}', [  
    'uses' => '[email protected]', 
    'as' => 'dashboard2', 
    'middleware' => 'auth' 

]); 

所以我傳遞給它的這兩個變量如下:

查看代碼:

<a href="{{ route('post.pin', [      
          'wordsRowId' => $wordsRowId, 
          'wordsRowB' => $wordsRowB 
         ]) }}">Test</a> 

控制器代碼:

public function postPin($wordsRowId,$wordsRowB) 
    { 

     return redirect()->route('dashboard2') 
     ->with(['wordsRowId' => $wordsRowId]) 
     ->with(['wordsRowB' => $wordsRowB]); 

我得到這個錯誤:

(你會發現在錯誤2個更多的變量,那我爲了清楚上面的代碼中刪除)
Missing required parameters for [Route: dashboard2] [URI: dashboard2/{wordsRowB}/{wordsRowId}]. 
in UrlGenerationException.php line 17 
at UrlGenerationException::forMissingParameters(object(Route)) in UrlGenerator.php line 332 
at UrlGenerator->toRoute(object(Route), array(), true) in UrlGenerator.php line 304 
at UrlGenerator->route('dashboard2', array()) in Redirector.php line 157 
at Redirector->route('dashboard2') in DashController.php line 323 
at DashController->postPin('62', '1', '39', 'kokowawa') 
at call_user_func_array(array(object(DashController), 'postPin'), array('post_id' => '62', 'user_id' => '1', 'wordsRowB' => '39', 'wordsRowId' => 'kokowawa')) in Controller.php line 80 

請注意,使用var_dump顯示變量傳遞給postPin函數,但我不知道如何檢查它們是否被成功重定向到路線?

回答

1

我認爲你的變量需要是路線()調用

嘗試返回重定向()內 - >航線( 'dashboard2',[$ wordsRowId,$ wordsRowB]);

+0

數組語法起作用。謝謝 –