php – Is there any behaviour difference for Request files in laravel api and web?-ThrowExceptions

Exception or error:

I have created similar, but two different Request files for an api controller and web controller.
I used same middleware for both to change the request parameter.

Middleware code

$request['size'] = min(20000, 1); 
return $next($request);

When I dump, in API request and Web request like following,

dd($this->size);

the output for API is “20000” and Web is “1”. Also, please note that

dd($this->request->all());

Outputs :
[
  'size' => "1"
] 

for both. I want to know how $this->size shows different value in both requests.

How to solve:
dd($this->size);

it will give you the size of $size variable in class not the value of $request , check whether you have defined size variable in class.

Leave a Reply

Your email address will not be published. Required fields are marked *