- 모델: BusinessCardRequest (pending/processed 상태 관리)
- 서비스: 신청/처리/통계/뱃지 카운트
- 컨트롤러: 관리자 2분할 뷰, 파트너 신청폼+이력
- 뷰: admin-index (대기/처리완료 2분할), partner-index (신청폼+이력)
- 라우트: GET/POST /sales/business-cards, POST /{id}/process
- 뱃지: ViewServiceProvider에 대기 건수 연동
80 lines
2.8 KiB
PHP
80 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\Tenants\Tenant;
|
|
use App\Services\Sales\BusinessCardRequestService;
|
|
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()) {
|
|
// 테넌트가 선택되지 않은 경우 자동으로 HQ 테넌트 설정
|
|
if (! session('selected_tenant_id')) {
|
|
$hqTenant = auth()->user()->getHQTenant();
|
|
if ($hqTenant) {
|
|
session(['selected_tenant_id' => $hqTenant->id]);
|
|
}
|
|
}
|
|
|
|
$globalTenants = Tenant::active()
|
|
->orderBy('company_name')
|
|
->get(['id', 'company_name', 'code']);
|
|
|
|
$view->with('globalTenants', $globalTenants);
|
|
}
|
|
});
|
|
|
|
// 사이드바 메뉴 뱃지 데이터 (전역 공유 - 컴포넌트에서도 접근 가능)
|
|
View::composer('partials.sidebar', function ($view) {
|
|
$menuBadges = [
|
|
'byRoute' => [], // 라우트명 기준
|
|
'byUrl' => [], // URL 기준
|
|
];
|
|
|
|
if (auth()->check()) {
|
|
try {
|
|
$salesManagerService = app(SalesManagerService::class);
|
|
$approvalStats = $salesManagerService->getApprovalStats();
|
|
|
|
// 영업파트너 승인 대기 건수
|
|
if ($approvalStats['pending'] > 0) {
|
|
$menuBadges['byRoute']['sales.managers.approvals'] = $approvalStats['pending'];
|
|
$menuBadges['byUrl']['/sales/managers/approvals'] = $approvalStats['pending'];
|
|
}
|
|
|
|
// 명함신청 대기 건수
|
|
$businessCardService = app(BusinessCardRequestService::class);
|
|
$businessCardPending = $businessCardService->getPendingCount();
|
|
if ($businessCardPending > 0) {
|
|
$menuBadges['byRoute']['sales.business-cards.index'] = $businessCardPending;
|
|
$menuBadges['byUrl']['/sales/business-cards'] = $businessCardPending;
|
|
}
|
|
} catch (\Exception $e) {
|
|
// 서비스 오류 시 무시
|
|
}
|
|
}
|
|
|
|
// View::share로 전역 공유 (Blade 컴포넌트에서도 접근 가능)
|
|
View::share('menuBadges', $menuBadges);
|
|
});
|
|
}
|
|
}
|