ldc-com-app-bo/app/Providers/ViewServiceProvider.php

34 lines
940 B
PHP
Raw Normal View History

2023-03-27 12:17:31 +02:00
<?php
namespace App\Providers;
2025-05-20 16:20:23 +02:00
use App\Models\Tenant;
2023-03-27 12:17:31 +02:00
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Schema;
2025-05-20 16:20:23 +02:00
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
2023-03-27 12:17:31 +02:00
class ViewServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot(): void
2023-03-27 12:17:31 +02:00
{
if (!app()->runningInConsole()) {
// * FORCE BOOTSTRAP PAGINATOR (or custom if in front)
// Early boot, request wont be filled as expected.
if (collect(explode('/', \request()->getPathInfo()))->get(1) === 'bo') {
Paginator::defaultview('bo.modules.pagination');
} else {
Paginator::useBootstrap();
}
if (Schema::hasTable('tenants')) {
View::share('tenantsGlobal', Tenant::getTenantsCached());
}
}
2023-03-27 12:17:31 +02:00
}
}