AppServiceProvider.php 873 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace App\Providers;
  3. use App\Tools\ApiPaginator;
  4. use Illuminate\Pagination\LengthAwarePaginator;
  5. use Illuminate\Support\ServiceProvider;
  6. class AppServiceProvider extends ServiceProvider
  7. {
  8. /**
  9. * Register any application services.
  10. */
  11. public function register(): void
  12. {
  13. if ($this->app->environment('local')) {
  14. $this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
  15. $this->app->register(TelescopeServiceProvider::class);
  16. }
  17. }
  18. /**
  19. * Bootstrap any application services.
  20. */
  21. public function boot(): void
  22. {
  23. //
  24. $this->app->bind(LengthAwarePaginator::class, function ($app, $options) {
  25. return new ApiPaginator($options['items'], $options['total'], $options['perPage'], $options['currentPage'], $options['options']);
  26. });
  27. }
  28. }