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

timtom's avatar

Add parameter in request from Rules

Hello,

I would like to know if it is possible to add a parameter in request from a rule validation file.

Because in my rule, i make some sql requests but i need to do the same requests after the validation to get a parameter.

Maybe is it possible to prevent to do the sql requests twice and simply add the parameter that i got in my rule validation ?

Thanks

0 likes
1 reply
tykus's avatar
tykus
Best Answer
Level 104

Just cache the result - adding to the Request (while possible) is messy.

You can cache for the duration of the current Request if you use the array driver, e.g.

\Cache::driver('array')
	->rememberForever('key', fn() => Model::where('something', $request->input('some_key))->first());

You can fetch the cached data from the Cache elsewhere.

Please or to participate in this conversation.