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
));
}
}
어디에서 문제가 발생합니까? 그것을 더 잘 할 수있는 방법이 있습니까? 도움말 :)하십시오
이 방법으로 경로를 등록하면 액션 메서드를 사용할 필요가 없으므로 url :: to()를 사용할 수 있습니다. – keren