AppServiceProvider.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace App\Providers;
  3. use App\Contracts\PermissionMiddleware;
  4. use App\Http\Middleware\AdminPermission;
  5. use App\Models\Area;
  6. use App\Models\Bike;
  7. use App\Models\Parking;
  8. use App\Observers\AreaObserver;
  9. use App\Observers\BikeObserver;
  10. use App\Observers\ParkingObserver;
  11. use Illuminate\Http\Resources\Json\Resource;
  12. use Illuminate\Support\Facades\Log;
  13. use Illuminate\Support\ServiceProvider;
  14. use Overtrue\EasySms\EasySms;
  15. class AppServiceProvider extends ServiceProvider
  16. {
  17. /**
  18. * Register any application services.
  19. *
  20. * @return void
  21. */
  22. public function register()
  23. {
  24. //
  25. if ($this->app->isLocal()) {
  26. $this->app->register(TelescopeServiceProvider::class);
  27. }
  28. $this->app->singleton('easy_sms', function ($app) {
  29. $config = config('easySms');
  30. return (new EasySms($config));
  31. });
  32. }
  33. /**
  34. * Bootstrap any application services.
  35. *
  36. * @return void
  37. */
  38. public function boot()
  39. {
  40. Resource::withoutWrapping();
  41. $this->app->singleton(PermissionMiddleware::class, function () {
  42. return new AdminPermission();
  43. });
  44. Bike::observe(BikeObserver::class);
  45. Area::observe(AreaObserver::class);
  46. Parking::observe(ParkingObserver::class);
  47. }
  48. }