@raven_corwin
In Laravel, if you want to modify the request input after validation, you can use the merge()
method available on the request object.
Here's how you can do it:
- After validating the request using a validation rule or custom validation logic, you can retrieve the input values using the validated() method on the request object. This method returns the validated input values:
1
|
$validatedData = $request->validated();
|
- You can then modify the validated data as per your requirement.
- To modify the request input, you can use the merge() method on the request object. This method allows you to merge additional input values into the request's input data:
1
|
$request->merge(['key' => 'value']);
|
- You can now access the modified input using the usual syntax, for example:
1
|
$value = $request->input('key');
|
By following these steps, you should be able to modify the request input after validation in Laravel.