Extend Request class in Laravel 5

后端 未结 6 1386
猫巷女王i
猫巷女王i 2020-12-08 22:48

I\'m new to Laravel (only experienced Laravel 5, so no legacy hang up here)

I\'d like to know how to extend the core Request class. In addition to how to extend it,

6条回答
  •  有刺的猬
    2020-12-08 22:53

    I was working on the same issue today and I think it's worth mention that you may just change

    Illuminate\Http\Request::capture()
    

    to

    App\Http\CustomRequest::capture()
    

    without adding line

    $app->alias('request', 'App\Http\CustomRequest');
    

    because inside capture() method laravel actually binds provided class to service container with 'request' as a key

提交回复
热议问题