<?php

namespace App\Providers;

use App\Tools\ApiPaginator;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        if ($this->app->environment('local')) {
            $this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
            $this->app->register(TelescopeServiceProvider::class);
        }
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        //
        $this->app->bind(LengthAwarePaginator::class, function ($app, $options) {
            return new ApiPaginator($options['items'], $options['total'], $options['perPage'], $options['currentPage'], $options['options']);
        });
    }
}