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