dimanche 6 mars 2016

How to check the submitted date is not before the today's date in laravel 5 request class?

Here is my code in request class. public function rules() {

    return [
        'title' => 'required',
        'eventDate' => 'required|date|before:today',


    ];
}

public function messages(){
    return [
        'title.required' => 'Title is required.',
        'eventDate.before' => 'Event Date is already passed',
        'eventDate.required' => 'Event Date is required.',

    ];
}`

This is the view class code

@if($errors->has('eventDate.required'))
                    <p style="color: red">{{$errors->first('eventDate.required')}}</p>
                @endif
                @if($errors->has('eventDate.before'))
                    <p style="color: red">{{$errors->first('eventDate.before')}}</p>
                @endif

I want to compare the submitted date with today's date. If submitted date is earlier date than today's date, an error message should be displayed.

But exception comes like this. enter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire