Laravel代码片断

2019-02-11  本文已影响0人  豆豆_06fa

模板地址生成:

<a href="{{action('index@index',['id'=>3])}}">查看</a>


laravel表单:{{csrf_field()}}


中间件路由:

Route::group(['middleware'=>'userCheck'],function(){

    Route::get('/home','index@home');

    Route::group(['middleware' => 'adminCheck'], function () {

        Route::get('newsview/{id}','index@newsview');

    });

});


指定视图数据预加载

ServiceProvider中的boot:

public function boot()

    {

        //

                // view()->share('nav',$rs);

                view::composer('common.nav',function($e){

                    $rs=DB::table('newstype')->take(11)->get();

                    $e->with('nav',$rs);

                });

    }


上一篇 下一篇

猜你喜欢

热点阅读