As I understand it, I'm trying to prepare a special verification rule that can help you fulfill your requirements.
The current rule mentioned below only checks the start date before the end date.
<?php namespace App\Providers; use Validator; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider{ public function boot(){ Validator::extend('date_after', function($attribute, $value, $parameters) { return strtotime( $value ) > strtotime( $this->attributes[ $parameters[0] ] ); }); Validator::extend('date_equal', function($attribute, $value, $parameters) { return strtotime( $value ) == strtotime( $this->attributes[ $parameters[0] ] ); }); } } ?>
Using:
<?php $inputs = array( 'start_date' => '2013-01-20', 'end_date' => '2013-01-15' ); $rules = array( 'start_date' => 'required', 'end_date' => 'required|date_after:start_date' ); $messages = array( 'date_after' => ":attribute must be date after Start Date." ); $validation = Validator::make($inputs, $rules, $messages); if( $validation->fails() ) { echo '<pre>'; print_r($validation->errors); echo '</pre>'; } ?>
However, I have not tested this code with my env ... but I believe that it helps you deal with the requirements.
Please let me know your further requirement so that I can provide you with a specific solution to your requirement.
source share