Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

amitshahc's avatar

custom Request creator class Illuminate\Http\Request changes behavior overnight.

This syntax to create custom $requestObject suddenly not working. without any changes in laravel version or update or package update.

Below code block was returning non-empty request object before 2 days. and now suddenly it returns empty.

$requestObj = new Request();
$requestObj->type = ($request->type) ? $request->type : '';
$requestObj->request->add(['vendor_id' => $request->vendor_id]);

Then I had to change it to this then working.

$requestObj = new Request([
    'type' => $request->type ?? '',
    'vendor_id' => $request->vendor_id,
 ]);

Can someone explain what exactly would have been happen here overnight?

0 likes
4 replies
jaseofspades88's avatar

Maybe the question should be ‘Are you taking data from the request to instantiate another request class?’

martinbean's avatar

@amitshahc Why on earth are you creating a “custom” request from the regular request? Just use the regular request.

amitshahc's avatar

@martinbean

  1. It wasn't me, I am working on someone else's code.
  2. The custom request is to pass the limited parameter from the current controller to another controller method. I am again not the right person for why it was written like that.

However, the concerns above do not address the anomaly in the behaviour of the Request() class. I would appreciate it if we all please stick to this syntax behaviour change overnight? That should be the only issue we should target. Refactoring the code is not what I am posting here for. That thing I have already handled.

Glukinho's avatar

Nobody can tell what changed overnight in your app except yourself.

The same code in the same environment gives the same result; if the result is different and the code didn't change then your environment has changed. Maybe your input data is different than the day before, maybe your code has dependency on a current date or day of week, there is a lot of options.

1 like

Please or to participate in this conversation.