AppServiceProvider.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Providers;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Queue\Events\JobFailed;
  5. use Illuminate\Support\Facades\Queue;
  6. use Illuminate\Support\Facades\Schema;
  7. use Illuminate\Support\ServiceProvider;
  8. use Validator;
  9. class AppServiceProvider extends ServiceProvider
  10. {
  11. /**
  12. * Register any application services.
  13. *
  14. * @return void
  15. */
  16. public function register()
  17. {
  18. //
  19. }
  20. /**
  21. * Bootstrap any application services.
  22. *
  23. * @return void
  24. */
  25. public function boot()
  26. {
  27. //
  28. Schema::defaultStringLength(191);
  29. Queue::failing(function (JobFailed $event) {
  30. (new Controller())->log(__METHOD__,'EventError_',"$event -> connectionName:{$event->connectionName},$event-> job:{$event->job},
  31. $event-> exception:{$event->exception}");
  32. });
  33. //扩展身份证验证规则
  34. Validator::extend('identity_cards', function($attribute, $value, $parameters) {
  35. return preg_match('/(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}$)/', $value);
  36. });
  37. }
  38. }