refactor: [business-card] 메뉴 2개로 분리 (파트너 명함신청 / 명함신청 처리)
- 파트너 명함신청 (/sales/business-cards): 모든 사용자 (신청폼+이력) - 명함신청 처리 (/sales/business-cards/manage): 관리자 전용 (2분할) - 뱃지를 manage 라우트에 연동
This commit is contained in:
@@ -15,7 +15,7 @@ public function __construct(
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 목록 페이지 (관리자: 관리뷰 / 파트너: 신청뷰)
|
||||
* 파트너 명함신청 (신청폼 + 이력) - 모든 사용자
|
||||
*/
|
||||
public function index(Request $request): View|Response
|
||||
{
|
||||
@@ -24,26 +24,37 @@ public function index(Request $request): View|Response
|
||||
}
|
||||
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->isAdmin()) {
|
||||
$search = $request->get('search');
|
||||
$stats = $this->service->getStats();
|
||||
$pendingRequests = $this->service->getPendingRequests($search);
|
||||
$processedRequests = $this->service->getProcessedRequests($search);
|
||||
|
||||
return view('sales.business-cards.admin-index', compact(
|
||||
'stats',
|
||||
'pendingRequests',
|
||||
'processedRequests',
|
||||
'search'
|
||||
));
|
||||
}
|
||||
|
||||
$myRequests = $this->service->getMyRequests($user->id);
|
||||
|
||||
return view('sales.business-cards.partner-index', compact('user', 'myRequests'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 명함신청 처리 (관리자 전용 - 대기/완료 2분할)
|
||||
*/
|
||||
public function manage(Request $request): View|Response
|
||||
{
|
||||
if ($request->header('HX-Request')) {
|
||||
return response('', 200)->header('HX-Redirect', route('sales.business-cards.manage'));
|
||||
}
|
||||
|
||||
if (! auth()->user()->isAdmin()) {
|
||||
abort(403, '관리자만 접근할 수 있습니다.');
|
||||
}
|
||||
|
||||
$search = $request->get('search');
|
||||
$stats = $this->service->getStats();
|
||||
$pendingRequests = $this->service->getPendingRequests($search);
|
||||
$processedRequests = $this->service->getProcessedRequests($search);
|
||||
|
||||
return view('sales.business-cards.admin-index', compact(
|
||||
'stats',
|
||||
'pendingRequests',
|
||||
'processedRequests',
|
||||
'search'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* 명함 신청 등록
|
||||
*/
|
||||
@@ -86,7 +97,7 @@ public function process(Request $request, int $id)
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect()->route('sales.business-cards.index')
|
||||
return redirect()->route('sales.business-cards.manage')
|
||||
->with('success', '처리가 완료되었습니다.');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user