Spaces:
Running
Running
| namespace App\Providers; | |
| use Illuminate\Routing\UrlGenerator; | |
| use Illuminate\Support\ServiceProvider; | |
| use Illuminate\Support\Collection; | |
| use Illuminate\Pagination\LengthAwarePaginator; | |
| class AppServiceProvider extends ServiceProvider | |
| { | |
| /** | |
| * Register any application services. | |
| */ | |
| public function register(): void | |
| { | |
| // | |
| } | |
| /** | |
| * Bootstrap any application services. | |
| */ | |
| public function boot(UrlGenerator $url): void | |
| { | |
| if (env('APP_ENV') == 'production') { | |
| $url->forceScheme('https'); | |
| }else{ | |
| $url->forceScheme('http'); | |
| } | |
| Collection::macro('paginate', function($perPage, $total = null, $page = null, $pageName = 'page') { | |
| $page = $page ?: LengthAwarePaginator::resolveCurrentPage($pageName); | |
| return new LengthAwarePaginator( | |
| $this->forPage($page, $perPage), | |
| $total ?: $this->count(), | |
| $perPage, | |
| $page, | |
| [ | |
| 'path' => LengthAwarePaginator::resolveCurrentPath(), | |
| 'pageName' => $pageName, | |
| ] | |
| ); | |
| }); | |
| } | |
| } | |