【发布时间】:2013-12-02 04:54:40
【问题描述】:
我希望在同一 url 级别访问两种类型的内容。
-
页面:
- mysite.com/about
- mysite.com/contact
-
类别:
- mysite.com/category-1
- mysite.com/category-2
我想根据特定的内容类型路由到控制器的方法。知道我该如何处理吗?
我的代码...
Route::get('{slug}', function($slug) {
$p = Page::where('slug', $slug)->first();
if (!is_null($p)) {
// How i can call a controller method here?
} else {
$c = Category::where('slug', $slug)->first();
if (!is_null($c)) {
// How i can call a another controller method here?
} else {
// Call 404 View...
}
}
});
【问题讨论】:
标签: php laravel laravel-4 laravel-routing