通过Laravel中的函数运行每个输入请求

Very new to Laravel. Trying to setup a simple contact form to familiarize myself with it. I send the form data via ajax and I process each input with this in javascript:

encodeURIComponent($("#contact-name").val())

How can I run all of those inputs through

urldecode()

on the php side without having to manually do each one?

For instance I want to use this:

$this->validate($request, [
        'name' => 'required',
        'email' => 'required|email',
        'message' => 'required'
]);

and I can't because the @ in an email address gets encoded so the validation rule for valid email returns false.

I need to have all the inputs in the request run through urldecode() and then get put back so I can use all the convenient stuff Laravel has to offer.

just before you $this->validate(... , write following code:

foreach($request->all() as $key => $value)
{   
    $request->merge(array( $key => urldecode($value) ));
}

above foreach loop will replace all input fields with their urldecoded values.