36 lines
736 B
PHP
36 lines
736 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Providers;
|
||
|
|
|
||
|
|
use App\Models\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()) {
|
||
|
|
$tenants = Tenant::active()
|
||
|
|
->orderBy('company_name')
|
||
|
|
->get(['id', 'company_name', 'code']);
|
||
|
|
|
||
|
|
$view->with('tenants', $tenants);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|