Files
sam-manage/app/Providers/ViewServiceProvider.php

36 lines
774 B
PHP
Raw Normal View History

<?php
namespace App\Providers;
use App\Models\Tenants\Tenant;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
class ViewServiceProvider extends ServiceProvider
{
/**
* Register services.
*/
public function register(): void
{
//
}
/**
* Bootstrap services.
*/
public function boot(): void
{
// 모든 뷰에 테넌트 목록 공유 (전역용)
View::composer('*', function ($view) {
if (auth()->check()) {
$globalTenants = Tenant::active()
->orderBy('company_name')
->get(['id', 'company_name', 'code']);
$view->with('globalTenants', $globalTenants);
}
});
}
}