Laravel Request Class prepareForValidation not reflected in $request->get

230 Views Asked by At

In a API endpoint taking "emails" as an array, I am validating values with a Request Class. In this Request class' prepareForValidation method:

$this->merge([
    'emails' => array_unique($this->emails)
]);

I have this lines. And a controller like this:

foreach ($request->get('emails') as $email) {
    //process
}

In local environment, I have no error or bug. It works expected. I am giving "[email protected]" twice, and it works only once. But in server (with octane, no other changes), when I give "[email protected]" twice again, it works twice.

I have finally solved the problem with using

$request->input()

instead of "$request->get()". But I am curious, why $request works fine in local but causing problems in server? Is it related to Octane? Has anyone encountered such a problem before?

0

There are 0 best solutions below