laravel,回想一下routes.php关闭内的资源路径

时间:2016-06-07 19:07:28

标签: laravel-5 controller routes

我已经实现了这段代码并且它有效, 函数从视图文件返回/生成html,我将view()方法添加到控制器

//i'm ok with this and did works
Route::get('/page/{name}', function($name){
    if(class_exists("App\Http\Controllers\\".$name."Ctrl")){
        return App::make("App\Http\Controllers\\".$name."Ctrl")->view();
    }
    else{
        return "Page tidak ditemukan";
    }
});

现在我想在资源路径上实现此功能,但无法找到技术/方法以与上面相同的方式运行

Route::resource('/data/{name}', function($name){

    //check first if controller exists
    if(class_exists("App\Http\Controllers\\".$name."Ctrl")){
        //need some Kind Of method or hack i presume
        // so the request is processed as defined by the standar resource route
        //
        //NEED HELP ON THIS FUNCTIONALITY
        //
    }
    else{
        return "Page tidak ditemukan";
    }
});

0 个答案:

没有答案