- ViewServiceProvider: App\Models\Tenant → App\Models\Tenants\Tenant - User 모델에 tenant() 관계 추가
36 lines
744 B
PHP
36 lines
744 B
PHP
<?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()) {
|
|
$tenants = Tenant::active()
|
|
->orderBy('company_name')
|
|
->get(['id', 'company_name', 'code']);
|
|
|
|
$view->with('tenants', $tenants);
|
|
}
|
|
});
|
|
}
|
|
}
|