40 lines
723 B
PHP
40 lines
723 B
PHP
<?php namespace App\Providers;
|
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Validator;
|
|
|
|
class ValidatorServiceProvider extends ServiceProvider {
|
|
|
|
public function boot()
|
|
{
|
|
$this->app['validator']->extend('multidate_format', function ($attribute, $value, $parameters)
|
|
{
|
|
if(is_string($value))
|
|
{
|
|
$value = explode(',', $value);
|
|
}
|
|
|
|
$input = array();
|
|
$tests = array();
|
|
foreach ($value as $v)
|
|
{
|
|
$input[$attribute] = $v;
|
|
if(count($parameters))
|
|
{
|
|
$tests[$attribute] = 'date_format:'.$parameters[0];
|
|
}
|
|
$validator = Validator::make($input, $tests);
|
|
if($validator->fails())
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
});
|
|
}
|
|
|
|
public function register()
|
|
{
|
|
//
|
|
}
|
|
} |