2016-02-19 42 views
0

蛞蝓重定向我有以下控制器:如何使用Laravel

public function postupdate($subject, $id) 

//my code 

return Redirect::route('webupdate'); // This code is wrong 

下面的路線是,我要重新導向,但我怎麼重定向而包括從上面的控制器都蛞蝓?

路線:

Route::get('/updateweb/{subject}/{id}/', array('as' => 'webupdate', 'uses' => '[email protected]')); 

回答

0
return Redirect::route('webupdate', ['subject'=>$subject, 'id'=>$id]); 

OR

return Redirect::route('webupdate', [$subject, $id]); 
+0

它不工作。當我重定向時,我想要包含在網址中的slu gs。 btw即時通訊使用Laravel 4.2 – Billy

+0

嘗試第一個選項。這將使用'$ subject'和'$ id'將用戶重定向到roue'webupdate'。 –

+0

仍然無效 – Billy

0

只需

return Redirect::route('webupdate', array($subject, $id)); 

return Redirect::route('webupdate', array('subject' => $subject, 'id' => $id)); 

如果你只有一個金屬塊,你也可以做

return Redirect::route('routename', $id); 

瞭解更多關於Redirects in Laravel 4.2 here

+0

與我的答案有什麼不同? –

+0

你現在添加了你的答案的關鍵。 @JilsonThomas – ahmet2106

+0

查看我的編輯歷史。 :) –