Support the ongoing development of Laravel.io →
Requests Input

Hello,

Here my case.

I need to filter data send to $request->get('filters') and delete invalid subdata before making a replace.

So, I'm doing something like this:

$arrFilters = $request->get('filters');

foreach ($arrFilters as $fieldName => $arrValue) { $fieldValidator = Validator::make( ['field' => $fieldName], AdvertConfigField::$validationRules['search'] );

if ($fieldValidator->fails()) { unset($arrFilters[$fieldName]); } }

$request->replace(['filters' => $arrFilters]);

Then, if I make a dd() of $request->all() or a dd() of $request-input('filters'), I received the correct filtered information.

But, if I make a $request->get('filters'), I always received the non-filtered data.

How is it possible?

Thx, Olivier

Last updated 3 years ago.
0

Laravel Request class does not have 'get' method. It inherits it form Symfony Request class. All modifications happens on Laravels ParameterBag, so when dumping all or input you get modified result. Get method just gets raw data again.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

oranocha oranocha Joined 1 Apr 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.