欢迎各位兄弟 发布技术文章
这里的技术是共享的
public function boot()
{ // Validator::extend('mobile', function($attribute, $value, $parameters) { return preg_match('/^1[123456789][0-9]{9}$/', $value) || preg_match('/^[0-9]{10}$/', $value); }); Validator::extend('officephone', function($attribute, $value, $parameters) { return preg_match('/^[0-9]{3,4}\-[0-9]{7,8}$/', $value); }); Validator::extend('fouroophone', function($attribute, $value, $parameters) { return preg_match('/^[0-9]{3}\-[0-9]{3}\-[0-9]{4}$/', $value) || preg_match('/^[0-9]{3}\-[0-9]{4}\-[0-9]{3}$/', $value); }); Validator::extend('postcode', function($attribute, $value, $parameters) { return preg_match('/^[0-9]{6}$/', $value); }); Validator::extend('parent_id_same_me', function($attribute, $value, $parameters) { $parameters = Request::route()->parameters(); return !(!empty($parameters) && $parameters['categorys'] == $value); }); Validator::extend('answer_two_required', function($attribute, $value, $parameters) { if(!empty($value)){ $question_answer_two = Request::input('question_answer_two'); if(empty($question_answer_two)){ return false; } } return true; }); }