Overriding the form values before validate

Submitted by venkat556 - 1 week ago

Sometimes we need to change or modify the values before validating. It is possible to achieve this with overriding in Request.

// Your prepared request

namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;

class OrganizationRequest extends FormRequest
    // to modifying the input vlaues
    public function all()
        $all = parent::all();

        //then do your operation
        if (@$all['document_url'] == 'http://') {
            $all['document_url'] = '';
        return $all;
//in your rules
    public function rules()
        $rules['web_address'] = 'nullable|url';
         return $rules;
comments powered by Disqus