插件路由前缀

后台:admin.plugin.插件模块.名字
前台:plugin.插件模块.名字

插件路由前台文件

例如:app/Plugin/Note/frontRoute.php 里面正确写Laravel的路由规则即可。
例如

<?php

//绑定域名
$domain2 = config_cache('note.domain');
$path = config_cache('note.path');
$route='';
if($domain2)
{
    $route=Route::domain($domain2);
}else
{
    $route=Route::prefix($path?:'/docs/');
}
$route->namespace('Front')->group(function ($route) {
    //首页
    $route->get('/{book}.html', 'IndexController@index')->name('index');
    $route->get('/{book}/{show_id}.html', 'IndexController@show')->name('show');
});

?>

插件路由后台插件,也可以可以自己定义,但最后保持我给的,这样权限规则才不会乱。

<?php

Route::namespace('Admin')->group(function ($route) {

    //增删改查之类,这里引入
    $resource = [
        'NoteCateController',
        'NoteBookController',
        'NotePageController'
    ];
    //需要批量操作
    $more_add_controller = [
        'NoteCateController'

    ];
    //只需要首页
    $only_index_controller = [
        'HomeController'
    ];
    //只需要添加和首页
    $only_add_controller = [
        'ConfigController'
    ];
    //需要表格导入
    $import_add_controller = [
        'NoteCateController'
    ];

    foreach ($resource as $c) {
        //自动获取
        $controller = str_replace('Controller', '', $c);
        $controller_path = strtolower($controller);

        $route->group(['prefix' => $controller_path . '/'], function ($route) use ($c, $controller_path) {

            $route->get('/', $c . '@index')->name($controller_path . ".index");
            $route->get('create', $c . '@create')->name($controller_path . ".create");
            $route->get('show/{id}', $c . '@show')->name($controller_path . ".show");
            $route->post('store', $c . '@store')->name($controller_path . ".store");
            $route->get('edit/{id}', $c . '@edit')->name($controller_path . ".edit");
            $route->put('update/{id}', $c . '@update')->name($controller_path . ".update");
            $route->put('delete/', $c . '@destroy')->name($controller_path . ".destroy");
            $route->post('edit_list/', $c . '@editTable')->name($controller_path . ".edit_list");
        });

        $route->any($controller_path . '/list', ['uses' => $c . '@getList'])->name($controller_path . ".list");

        //增加批量操作
        if (in_array($c, $more_add_controller)) {
            $route->get($controller_path . '/all/create', ['uses' => $c . '@allCreate'])->name($controller_path . '.all_create');
            $route->post($controller_path . '/all/create/post', ['uses' => $c . '@allCreatePost'])->name($controller_path . '.all_create_post');
        }
        //导入操作
        if (in_array($c, $import_add_controller)) {
            $route->post($controller_path . '/import/post', ['uses' => $c . '@importPost'])->name($controller_path . '.import_post');
            $route->get($controller_path . '/import/tpl', ['uses' => $c . '@importTpl'])->name($controller_path . '.import_tpl');
        }
    }
    //只需要首页控制器
    foreach ($only_index_controller as $c) {
        $controller = str_replace('Controller', '', $c);
        $controller_path = strtolower($controller);
        $route->group(['prefix' => $controller_path . '/'], function ($route) use ($c, $controller_path) {
            $route->get('/', $c . '@index')->name($controller_path . ".index");
            $route->any($c . '/list', ['uses' => $c . '@getList'])->name($controller_path . ".list");
        });

    }
    //著需要添加和首页
    foreach ($only_add_controller as $c) {
        $controller = str_replace('Controller', '', $c);
        $controller_path = strtolower($controller);
        $route->group(['prefix' => $controller_path . '/'], function ($route) use ($c, $controller_path) {
            $route->get('/', $c . '@index')->name($controller_path . ".index");
            $route->post('store', $c . '@store')->name($controller_path . ".store");
            $route->any($c . '/list', ['uses' => $c . '@getList'])->name($controller_path . ".list");
        });

    }
});
?>

其他路由文件位置保持原位置,正常Laravel规则编写接口,后台遵循规则即可。