I have Model Leave in my laravel 5.1 application. I want to do following things
- Validate input data using Laravel FormRequest
- On successful validation format the input field for processing (eg. parsing date input string to Carbon object for processing)
- This processing is to be done before calling controller action, (ie controller action should receive formatted data)
I have a LeaveRequest class to do following things.
rules()method to provide validation rule array.- overridden method
all()to format the input data.
Problems 1. all() method is called before validation 2. I want to validate unformatted data (as is submitted through form) first and on successful validation format the same. 3. I don't want to call any function from controller to format data it should be handled by LeaveRequest class.
What approach should I use for this.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire