I get from response a formData, that I change into a middleware to use it on validation, the problem, is that I must do another modification to validate all elements from array without using 'array.oneElement'.
Code from Middleware
public function handle($request, Closure $next)
{
if ($request->has('all_values')) {
$request->merge([
'all_values' => json_decode($request->get('all_values'), true)
]);
}
return $next($request);
}
// From Requst
public function rules()
{
$validations = [
'all_values.saleforce_id' => 'required',
'all_values.customer_id' => 'required',
'all_values.lkp_product_category_id' => 'required',
]
// I need to access this all_values before validations
if (request()->has('validation_field')) {
return [request()->validation_field => $validations[ request()->validation_field ]];
} // this is used for a validation , to do validation onChange
return $validations;
}
$request = $request->all()['all_values']; // I need something like this, but this doesn't work