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");
        });
    });
    */
  • 相关阅读:
    git
    centos7安装python3和ipython
    centos7 安装mysql5.7
    ceph-文件存储
    ceph-对象存储
    ceph-块存储客户端
    ceph-简介及安装(luminous)版
    centos7 kvm安装使用
    webpack多页面应用打包问题-新增页面打包JS影响旧有JS资源
    webpack4.0 babel配置遇到的问题
  • 原文地址:https://www.cnblogs.com/lx0715/p/10043077.html
Copyright © 2011-2022 走看看