0
我开始与laravel,我需要做这样的事情 localhost/diretory1/directory2/directory3
Laravel 4自我关系嵌套路线
是可以设置它像一个嵌套的路线?目前它的工作是这样的 localhost/directory1
- >localhost/directory2
我开始与laravel,我需要做这样的事情 localhost/diretory1/directory2/directory3
Laravel 4自我关系嵌套路线
是可以设置它像一个嵌套的路线?目前它的工作是这样的 localhost/directory1
- >localhost/directory2
所以你可以做的是定义一个捕获所有请求的slug路由。 (请务必将请求结束最多只能在塞途径,如果没有别的匹配你定义一个路由上述其他途径)
Route::any('{slug}', function($slug){
$directories = explode('/', $slug);
// lookup the directory(ies) in the db, file system, etc
if(!$exists){
// when the directories don't exists, it's probably appropriate to throw a 404 Not found error.
App::abort(404);
}
}
你的路由功能(或控制器做什么,如果它变得太代码生活在routes.php)取决于你。我不知道你的应用程序是如何工作的,所以我无法帮助你。
目录名称应该是动态还是静态? – lukasgeiter 2014-11-06 20:21:07
他们是动态的,用户可以任意他们的名字。 – 2014-11-07 10:06:29
好的。最高3级还是无限级? – lukasgeiter 2014-11-07 10:07:57