Closed mostafa-rz closed 3 months ago
Laravel Framework isn't 100% strict type, while the doc block may say @var Illuminate\Contracts\Container\Container
if you convert it to strict type it needs to be defined as protected Container|null $container
since the parameter is not initiated within the constructor.
@crynobone
It is not type-hinted but it doesn't mean that you can break the parent class functionality. If it is a FormRequest()
, it must be possible to validate it by the Laravel Form Request Validation. When you remove the container, the Laravel authorize()
method fails, because it needs the container.
Description:
The Nova class
src/Http/Requests/LensCountRequest.php
inherits from the Laravel classsrc/Illuminate/Foundation/Http/FormRequest.php
. The LaravelFormRequest
has a container property that is not nullable. The container is null when a count request is sent to the backend.The reason is
LensCountRequest()->toQuery()
method recreates the request byLensRequest::createFrom($this)
method. This results in a new request object but without the container. You can see the usage of this method in LaravelFormRequestServiceProvider()
. After they called theFormRequest::createFrom()
, they also set the container and redirectors again. Please consider this inLensCountRequest()->toQuery()
so the newly created request contains the container property.Detailed steps to reproduce the issue on a fresh Nova installation:
apply()
method of the filter check the$request
when the count request is reach there$request
object doesn't contain the container