zoukankan      html  css  js  c++  java
  • laravel-3-laravel路由与控制器链接

    <?php
    
    /*
    |--------------------------------------------------------------------------
    | Web Routes
    |--------------------------------------------------------------------------
    |
    | Here is where you can register web routes for your application. These
    | routes are loaded by the RouteServiceProvider within a group which
    | contains the "web" middleware group. Now create something great!
    |
    */
    
    Route::get('/', function () {
        return view('welcome');
    });
    
    Route::get('abc', function() {
        return view('artcle');
    });
    
    /*Route::get('artcle/index', "ArtcleController@index");
    Route::get('artcle/create', "ArtcleController@create");
    Route::post('artcle/store', "ArtcleController@store");
    
    */
    // 路由组
    
    Route::prefix('artcle')->group(function() {
        Route::get('index', 'ArtcleController@index');
        Route::get('create', 'ArtcleController@create');
        Route::post('store', 'ArtcleController@store');
    });
    
    //新目录控制器路由
    // Route::get('admin/admin/index', "AdminAdminController@index");
    // Route::get('admin/admin/create', "AdminAdminController@create");
    // Route::post('admin/admin/store', "AdminAdminController@store");
    
    // 多级目录路由组
    /*Route::prefix('admin/admin')->namespace('Admin')->group(function() {
        Route::get('index', "AdminController@index");
        Route::get('create', "AdminController@create");
        Route::post('store', "AdminController@store");
    });*/
    
    // 或者多级路由组嵌套使用 适用于目录下有多个控制器
    Route::prefix('admin')->namespace('Admin')->group(function() {
        Route::prefix('admin')->group(function() {
            Route::get('index', "AdminController@index");
            Route::get('create', "AdminController@create");
            Route::post('store', "AdminController@store");
        });
        Route::prefix('tag')->group(function() {
            Route::get('index', "TagController@index");
            Route::get('create', "TagController@create");
            Route::post('store', "TagController@store");
        });
    });
    
    // 远古写法
    /*Route::group(['prefix' => 'admin', 'namespace' => 'Admin'], function() {
        Route::group(['prefix' => 'admin'], function() {
            Route::get('index', "AdminController@index");
            Route::get('create', "AdminController@create");
            Route::post('store', "AdminController@store");
        });
        Route::group(['prefix' => 'tag'], function() {
            Route::get('index', "TagController@index");
            Route::get('create', "TagController@create");
            Route::post('store', "TagController@store");
        });
    });
    */
  • 相关阅读:
    SDN作业(4)
    SDN作业(3)
    第一次个人编程作业
    SDN作业(2)
    SDN作业(1)
    第一次博客作业
    浅谈闭包
    预编译And作用域链
    定时器
    window事件
  • 原文地址:https://www.cnblogs.com/lx0715/p/10043077.html
Copyright © 2011-2022 走看看