- ViewServiceProvider에서 메뉴별 뱃지 데이터 전달 - 영업파트너 승인 대기 건수 뱃지 표시 - menu-item 컴포넌트에서 뱃지 렌더링 (빨간색 원형) - 99개 초과 시 "99+" 표시 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
58 lines
1.6 KiB
PHP
58 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\Tenants\Tenant;
|
|
use App\Services\Sales\SalesManagerService;
|
|
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);
|
|
}
|
|
});
|
|
|
|
// 사이드바 메뉴 뱃지 데이터 (라우트명 => 건수)
|
|
View::composer('partials.sidebar', function ($view) {
|
|
$menuBadges = [];
|
|
|
|
if (auth()->check()) {
|
|
try {
|
|
$salesManagerService = app(SalesManagerService::class);
|
|
$approvalStats = $salesManagerService->getApprovalStats();
|
|
|
|
// 영업파트너 승인 대기 건수
|
|
if ($approvalStats['pending'] > 0) {
|
|
$menuBadges['sales.managers.approvals'] = $approvalStats['pending'];
|
|
}
|
|
} catch (\Exception $e) {
|
|
// 서비스 오류 시 무시
|
|
}
|
|
}
|
|
|
|
$view->with('menuBadges', $menuBadges);
|
|
});
|
|
}
|
|
}
|