feat: 테넌트 선택 기능 구현
- Tenant 모델 생성 (SoftDeletes, active scope) - TenantController 전환 컨트롤러 - ViewServiceProvider로 모든 뷰에 테넌트 데이터 자동 제공 - partials/tenant-selector.blade.php UI 컴포넌트 기능: - 드롭다운으로 테넌트 전환 (전체 보기 포함) - Session 기반 선택 상태 저장 - 우측에 현재 테넌트 정보 표시 - 모든 페이지에서 @include로 사용 가능 이슈 해결: - is_active 컬럼 없음 → tenant_st_code + deleted_at 사용 - 삭제되지 않은 모든 테넌트 표시 (7개)
This commit is contained in:
35
app/Providers/ViewServiceProvider.php
Normal file
35
app/Providers/ViewServiceProvider.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user