zoukankan      html  css  js  c++  java
  • laravel基础课程---5、路由复习(路由作用)

    laravel基础课程---5、路由复习(路由作用)

    一、总结

    一句话总结:

    有利于百度收录,及SEO优化

    1、路由书写 (D:laravelyzmeduyzm2 outesweb.php)?

    Route::get('/',function(){
    Route::get('/',function(){
        echo "云知梦";
    });
    
    Route::get('admin',function(){
        return view();
    
    });
    
    Route::get('admin/user',"UserController@index");

    2、路由类型?

    六种
    Route::get($uri, $callback);
    Route::post($uri, $callback);
    Route::put($uri, $callback);
    Route::patch($uri, $callback);
    Route::delete($uri, $callback);
    Route::options($uri, $callback);

    3、CSRF保护?

    {{csrf_field}}

    4、模拟PUT请求、delete请求?

    {{csrf_field}}
    input type="hidden" name="_method" value="put"

    5、路由带参数?

    大括号:Route::get("goods_info/{id}",'IndexController@index')
    Route::get("goods_info/{id}",function($id){
        echo "$id";
    });
    
    Route::get("goods_info/{id}",'IndexController@index')

    6、设置默认值?

    问号:Route::get("goods_info/{id?}",function($id='默认值'){
    Route::get("goods_info/{id?}",function($id='默认值'){
        echo "$id";
    });

    7、命名路由?

    Route::get('/','IndexController@index')->name('abc');

    8、路由组?

    命名空间,前缀,中间件:Route::group(['namespace'=>'','prefix'=>'','middleware'=>''],function(){
    Route::group(['namespace'=>'','prefix'=>'','middleware'=>''],function(){
    
    });

    9、资源路由?

    Route::recourse('admin/user','UserController');

    二、内容在总结中

     
  • 相关阅读:
    如何使用设计模式系列
    网站性能越来越差怎么办
    ASP.NET特殊字符串替换函数
    SQL Server多事务并发问题
    弹出隐藏子菜单
    过滤sql匹配符号 防止sql注入
    统一建模语言UML轻松入门系列
    sql 字符处理函数大全
    并发控制
    类与类之间的关系图
  • 原文地址:https://www.cnblogs.com/Renyi-Fan/p/10834788.html
Copyright © 2011-2022 走看看