fix: [approvals] 완료함에 기안자 본인의 완료 문서도 표시
- 기존: 결재자로 처리한 문서만 조회 - 수정: 내가 기안한 완료/반려/회수 문서 + 결재자로 처리한 문서 모두 조회
This commit is contained in:
@@ -62,14 +62,26 @@ public function getPendingForMe(int $userId, array $filters = [], int $perPage =
|
||||
}
|
||||
|
||||
/**
|
||||
* 처리 완료함 (내가 결재한 문서)
|
||||
* 처리 완료함 (내가 기안한 완료 문서 + 내가 결재 처리한 문서)
|
||||
*/
|
||||
public function getCompletedByMe(int $userId, array $filters = [], int $perPage = 15): LengthAwarePaginator
|
||||
{
|
||||
$query = Approval::with(['form', 'drafter', 'steps.approver'])
|
||||
->whereHas('steps', function ($q) use ($userId) {
|
||||
$q->where('approver_id', $userId)
|
||||
->whereIn('status', [ApprovalStep::STATUS_APPROVED, ApprovalStep::STATUS_REJECTED]);
|
||||
->where(function ($q) use ($userId) {
|
||||
// 내가 기안한 완료/반려/회수 문서
|
||||
$q->where(function ($sub) use ($userId) {
|
||||
$sub->where('drafter_id', $userId)
|
||||
->whereIn('status', [
|
||||
Approval::STATUS_APPROVED,
|
||||
Approval::STATUS_REJECTED,
|
||||
Approval::STATUS_CANCELLED,
|
||||
]);
|
||||
})
|
||||
// 또는 내가 결재자로 처리한 문서
|
||||
->orWhereHas('steps', function ($sub) use ($userId) {
|
||||
$sub->where('approver_id', $userId)
|
||||
->whereIn('status', [ApprovalStep::STATUS_APPROVED, ApprovalStep::STATUS_REJECTED]);
|
||||
});
|
||||
});
|
||||
|
||||
$this->applyFilters($query, $filters);
|
||||
|
||||
Reference in New Issue
Block a user