jeudi 5 janvier 2017

Laravel Changing Request data in Form Request Class

I'm processing a form with multiple date input which is not in A.D. For validation purpose i'm using Form Request.

Before validation and inserting in my database date input must be converted into A.D, so that i can do the proper validation & then if validation succeed date input is stored in A.D .

here is my code for converting date input in A.D

<?php

abstract class Request extends FormRequest
{
    public function all()
    {

       $input = parent::all()

       foreach ($input as $key=>$value)
       {
            if (substr($key, -5) == "_date")
            {
                $input[$key] = Helper::convert_in_ad($value);
            }
       }
       return $input;
    }
}

Now the problem is suppose you have failed validation and redirect back to the previous action and you then use old() or some other method to access the request data from the session, it will be modified, and i cannot get the the original data.

How can i change the date input in A.D when before validation so that i can properly validate in A.D and then store all the date input in A.D. by solving failed validation problem having modified input.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2ii5GDk
via IFTTT

Aucun commentaire:

Enregistrer un commentaire