<?php namespace App\Providers; use Illuminate\Pagination\Paginator; use Illuminate\Support\ServiceProvider; use Illuminate\Support\Collection; use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Routing\UrlGenerator; class AppServiceProvider extends ServiceProvider { /** * Register any application services. * * @return void */ public function register() { // } /** * Bootstrap any application services. * * @return void */ public function boot(UrlGenerator $url) { if (env('APP_ENV') !== 'local') { //so you can work on it locally dd(env('APP_ENV')); $url->forceScheme('https'); } Paginator::useBootstrap(); Collection::macro('paginate', function($perPage, $total = null, $page = null, $pageName = 'page'): LengthAwarePaginator { $page = $page ?: LengthAwarePaginator::resolveCurrentPage($pageName); return new LengthAwarePaginator( $this->forPage($page, $perPage)->values(), $total ?: $this->count(), $perPage, $page, [ 'path' => LengthAwarePaginator::resolveCurrentPath(), 'pageName' => $pageName, ] ); }); } }