Extend Request class in Laravel 5

后端 未结 6 1400
猫巷女王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 23:17

    In Laravel 5.5.x, I was able to extend the Request class for specific requests using the following:

    ExtendedRequest class

    ExtendedRequestServiceProvider

    app->singleton(ExtendedRequest::class, function ($app) {
                return ExtendedRequest::capture();
            });
        }
    }
    

    Then in your Controllers

    hello();
        }
    }
    

    Hope this helps someone.

提交回复
热议问题