2014-01-28 2 views
4

현재 Laravel 4에 문제가 있습니다. 포럼 카테고리 및 포럼 주제에 슬러그를 사용하고 싶습니다 (슬러그는 고유합니다). 사용자가 카테고리 또는 주제에있는 경우 따지기 위해,이 경로가 :Laravel 4 Redirect :: action() "Route not defined"

Route::get('forum/{slug}', function($slug) { 

    $category = ForumCategory::where('slug', '=', $slug)->first(); 

    if (!is_null($category)) 
     return Redirect::action('[email protected]', array('slug' => $slug)); 

    else { 

     $topic = ForumTopic::where('slug', '=', $slug)->first(); 

     if (!is_null($topic)) 
      return Redirect::action('[email protected]', array('slug' => $slug)); 

     else 
      return 'fail'; 

    } 

}); 

을 내가 범주에 도달하려고 할 때 다음과 같은 오류가 있습니다

Route [[email protected]] not defined.

내 포럼 카테고리 컨트롤러 :

class ForumCategoryController extends BaseController { 

    public function findBySlug($slug) { 

     $category = ForumCategory::where('slug', '=', $slug)->first(); 

     return View::make('forum.category', array(
      'title'   => 'Catégorie', 
      'category'  => $category 
     )); 

    } 

} 

어디에서 문제가 발생합니까? 그것을 더 잘 할 수있는 방법이 있습니까? 도움말 :)하십시오

답변

4
Laravel 당신이 Route::action()를 사용하는 경로를 정의 할 필요가 있다고 말하고있다

, 뭔가 같은 :

Route::get('forum/bySlug/{slug}', '[email protected]'); 

실제로 URL을 구축하고 consumme 것이기 때문에 :

http://your-box/forum/bySlug/{slug} 

그것을 위해서 당신의 행동을 가리키는 경로를 찾아야 만합니다.

+1

이 방법으로 경로를 등록하면 액션 메서드를 사용할 필요가 없으므로 url :: to()를 사용할 수 있습니다. – keren