2025-11-21 09:18:19 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
|
2025-11-24 08:50:44 +09:00
|
|
|
use App\Models\Tenants\Tenant;
|
2025-11-21 09:18:19 +09:00
|
|
|
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
|
|
|
|
|
{
|
2025-11-24 11:17:31 +09:00
|
|
|
// 모든 뷰에 테넌트 목록 공유 (전역용)
|
2025-11-21 09:18:19 +09:00
|
|
|
View::composer('*', function ($view) {
|
|
|
|
|
if (auth()->check()) {
|
2025-11-24 11:17:31 +09:00
|
|
|
$globalTenants = Tenant::active()
|
2025-11-21 09:18:19 +09:00
|
|
|
->orderBy('company_name')
|
|
|
|
|
->get(['id', 'company_name', 'code']);
|
|
|
|
|
|
2025-11-24 11:17:31 +09:00
|
|
|
$view->with('globalTenants', $globalTenants);
|
2025-11-21 09:18:19 +09:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|