feat: 휴가 관리 API 구현 (Phase 1)
- leaves, leave_balances 테이블 마이그레이션 추가 - Leave, LeaveBalance 모델 구현 (BelongsToTenant, SoftDeletes) - LeaveService 서비스 구현 (CRUD, 승인/반려/취소, 잔여일수 관리) - LeaveController 및 FormRequest 5개 생성 - API 엔드포인트 11개 등록 (/v1/leaves/*) - Swagger 문서 (LeaveApi.php) 작성 - i18n 메시지 키 추가 (message.leave.*, error.leave.*)
This commit is contained in:
146
app/Http/Controllers/Api/V1/LeaveController.php
Normal file
146
app/Http/Controllers/Api/V1/LeaveController.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use App\Helpers\ApiResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Leave\BalanceRequest;
|
||||
use App\Http\Requests\Leave\IndexRequest;
|
||||
use App\Http\Requests\Leave\RejectRequest;
|
||||
use App\Http\Requests\Leave\StoreRequest;
|
||||
use App\Http\Requests\Leave\UpdateRequest;
|
||||
use App\Services\LeaveService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LeaveController extends Controller
|
||||
{
|
||||
public function __construct(private LeaveService $service) {}
|
||||
|
||||
/**
|
||||
* 휴가 목록 조회
|
||||
* GET /v1/leaves
|
||||
*/
|
||||
public function index(IndexRequest $request): JsonResponse
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->service->index($request->validated());
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 휴가 상세 조회
|
||||
* GET /v1/leaves/{id}
|
||||
*/
|
||||
public function show(int $id): JsonResponse
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
return $this->service->show($id);
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 휴가 신청
|
||||
* POST /v1/leaves
|
||||
*/
|
||||
public function store(StoreRequest $request): JsonResponse
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->service->store($request->validated());
|
||||
}, __('message.leave.created'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 휴가 수정
|
||||
* PATCH /v1/leaves/{id}
|
||||
*/
|
||||
public function update(int $id, UpdateRequest $request): JsonResponse
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id, $request) {
|
||||
return $this->service->update($id, $request->validated());
|
||||
}, __('message.updated'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 휴가 삭제
|
||||
* DELETE /v1/leaves/{id}
|
||||
*/
|
||||
public function destroy(int $id): JsonResponse
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
return $this->service->destroy($id);
|
||||
}, __('message.deleted'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 휴가 승인
|
||||
* POST /v1/leaves/{id}/approve
|
||||
*/
|
||||
public function approve(int $id, Request $request): JsonResponse
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id, $request) {
|
||||
return $this->service->approve($id, $request->input('comment'));
|
||||
}, __('message.leave.approved'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 휴가 반려
|
||||
* POST /v1/leaves/{id}/reject
|
||||
*/
|
||||
public function reject(int $id, RejectRequest $request): JsonResponse
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id, $request) {
|
||||
return $this->service->reject($id, $request->input('reason'));
|
||||
}, __('message.leave.rejected'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 휴가 취소
|
||||
* POST /v1/leaves/{id}/cancel
|
||||
*/
|
||||
public function cancel(int $id, Request $request): JsonResponse
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id, $request) {
|
||||
return $this->service->cancel($id, $request->input('reason'));
|
||||
}, __('message.leave.cancelled'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 내 잔여 휴가 조회
|
||||
* GET /v1/leaves/balance
|
||||
*/
|
||||
public function balance(Request $request): JsonResponse
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->service->getMyBalance($request->input('year'));
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 사용자 잔여 휴가 조회
|
||||
* GET /v1/leaves/balance/{userId}
|
||||
*/
|
||||
public function userBalance(int $userId, Request $request): JsonResponse
|
||||
{
|
||||
return ApiResponse::handle(function () use ($userId, $request) {
|
||||
return $this->service->getUserBalance($userId, $request->input('year'));
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 잔여 휴가 설정
|
||||
* PUT /v1/leaves/balance
|
||||
*/
|
||||
public function setBalance(BalanceRequest $request): JsonResponse
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
$data = $request->validated();
|
||||
|
||||
return $this->service->setBalance(
|
||||
$data['user_id'],
|
||||
$data['year'],
|
||||
$data['total_days']
|
||||
);
|
||||
}, __('message.updated'));
|
||||
}
|
||||
}
|
||||
22
app/Http/Requests/Leave/BalanceRequest.php
Normal file
22
app/Http/Requests/Leave/BalanceRequest.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Leave;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class BalanceRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => 'required|integer|exists:users,id',
|
||||
'year' => 'required|integer|min:2020|max:2099',
|
||||
'total_days' => 'required|numeric|min:0|max:365',
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/Leave/IndexRequest.php
Normal file
30
app/Http/Requests/Leave/IndexRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Leave;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class IndexRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => 'nullable|integer',
|
||||
'status' => 'nullable|string|in:pending,approved,rejected,cancelled',
|
||||
'leave_type' => 'nullable|string|in:annual,half_am,half_pm,sick,family,maternity,parental',
|
||||
'date_from' => 'nullable|date',
|
||||
'date_to' => 'nullable|date|after_or_equal:date_from',
|
||||
'year' => 'nullable|integer|min:2020|max:2099',
|
||||
'department_id' => 'nullable|integer',
|
||||
'sort_by' => 'nullable|string|in:created_at,start_date,end_date,days,status',
|
||||
'sort_dir' => 'nullable|string|in:asc,desc',
|
||||
'per_page' => 'nullable|integer|min:1|max:100',
|
||||
'page' => 'nullable|integer|min:1',
|
||||
];
|
||||
}
|
||||
}
|
||||
27
app/Http/Requests/Leave/RejectRequest.php
Normal file
27
app/Http/Requests/Leave/RejectRequest.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Leave;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class RejectRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'reason' => 'required|string|max:1000',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'reason.required' => __('validation.required', ['attribute' => '반려사유']),
|
||||
];
|
||||
}
|
||||
}
|
||||
39
app/Http/Requests/Leave/StoreRequest.php
Normal file
39
app/Http/Requests/Leave/StoreRequest.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Leave;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => 'nullable|integer|exists:users,id',
|
||||
'leave_type' => 'required|string|in:annual,half_am,half_pm,sick,family,maternity,parental',
|
||||
'start_date' => 'required|date|after_or_equal:today',
|
||||
'end_date' => 'required|date|after_or_equal:start_date',
|
||||
'days' => 'required|numeric|min:0.5|max:365',
|
||||
'reason' => 'nullable|string|max:1000',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'leave_type.required' => __('validation.required', ['attribute' => '휴가유형']),
|
||||
'leave_type.in' => __('validation.in', ['attribute' => '휴가유형']),
|
||||
'start_date.required' => __('validation.required', ['attribute' => '시작일']),
|
||||
'start_date.after_or_equal' => __('validation.after_or_equal', ['attribute' => '시작일', 'date' => '오늘']),
|
||||
'end_date.required' => __('validation.required', ['attribute' => '종료일']),
|
||||
'end_date.after_or_equal' => __('validation.after_or_equal', ['attribute' => '종료일', 'date' => '시작일']),
|
||||
'days.required' => __('validation.required', ['attribute' => '사용일수']),
|
||||
'days.min' => __('validation.min.numeric', ['attribute' => '사용일수', 'min' => 0.5]),
|
||||
];
|
||||
}
|
||||
}
|
||||
24
app/Http/Requests/Leave/UpdateRequest.php
Normal file
24
app/Http/Requests/Leave/UpdateRequest.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Leave;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'leave_type' => 'nullable|string|in:annual,half_am,half_pm,sick,family,maternity,parental',
|
||||
'start_date' => 'nullable|date',
|
||||
'end_date' => 'nullable|date|after_or_equal:start_date',
|
||||
'days' => 'nullable|numeric|min:0.5|max:365',
|
||||
'reason' => 'nullable|string|max:1000',
|
||||
];
|
||||
}
|
||||
}
|
||||
260
app/Models/Tenants/Leave.php
Normal file
260
app/Models/Tenants/Leave.php
Normal file
@@ -0,0 +1,260 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Tenants;
|
||||
|
||||
use App\Models\Members\User;
|
||||
use App\Traits\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* 휴가 신청 모델
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $tenant_id
|
||||
* @property int $user_id
|
||||
* @property string $leave_type
|
||||
* @property string $start_date
|
||||
* @property string $end_date
|
||||
* @property float $days
|
||||
* @property string|null $reason
|
||||
* @property string $status
|
||||
* @property int|null $approved_by
|
||||
* @property string|null $approved_at
|
||||
* @property string|null $reject_reason
|
||||
* @property int|null $created_by
|
||||
* @property int|null $updated_by
|
||||
* @property int|null $deleted_by
|
||||
*/
|
||||
class Leave extends Model
|
||||
{
|
||||
use BelongsToTenant, SoftDeletes;
|
||||
|
||||
protected $table = 'leaves';
|
||||
|
||||
protected $casts = [
|
||||
'start_date' => 'date',
|
||||
'end_date' => 'date',
|
||||
'days' => 'decimal:1',
|
||||
'approved_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id',
|
||||
'user_id',
|
||||
'leave_type',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'days',
|
||||
'reason',
|
||||
'status',
|
||||
'approved_by',
|
||||
'approved_at',
|
||||
'reject_reason',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
protected $attributes = [
|
||||
'status' => 'pending',
|
||||
];
|
||||
|
||||
// =========================================================================
|
||||
// 상수 정의
|
||||
// =========================================================================
|
||||
|
||||
public const TYPE_ANNUAL = 'annual'; // 연차
|
||||
|
||||
public const TYPE_HALF_AM = 'half_am'; // 오전반차
|
||||
|
||||
public const TYPE_HALF_PM = 'half_pm'; // 오후반차
|
||||
|
||||
public const TYPE_SICK = 'sick'; // 병가
|
||||
|
||||
public const TYPE_FAMILY = 'family'; // 경조사
|
||||
|
||||
public const TYPE_MATERNITY = 'maternity'; // 출산
|
||||
|
||||
public const TYPE_PARENTAL = 'parental'; // 육아
|
||||
|
||||
public const STATUS_PENDING = 'pending';
|
||||
|
||||
public const STATUS_APPROVED = 'approved';
|
||||
|
||||
public const STATUS_REJECTED = 'rejected';
|
||||
|
||||
public const STATUS_CANCELLED = 'cancelled';
|
||||
|
||||
public const LEAVE_TYPES = [
|
||||
self::TYPE_ANNUAL,
|
||||
self::TYPE_HALF_AM,
|
||||
self::TYPE_HALF_PM,
|
||||
self::TYPE_SICK,
|
||||
self::TYPE_FAMILY,
|
||||
self::TYPE_MATERNITY,
|
||||
self::TYPE_PARENTAL,
|
||||
];
|
||||
|
||||
public const STATUSES = [
|
||||
self::STATUS_PENDING,
|
||||
self::STATUS_APPROVED,
|
||||
self::STATUS_REJECTED,
|
||||
self::STATUS_CANCELLED,
|
||||
];
|
||||
|
||||
// =========================================================================
|
||||
// 관계 정의
|
||||
// =========================================================================
|
||||
|
||||
/**
|
||||
* 신청자
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 승인자
|
||||
*/
|
||||
public function approver(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'approved_by');
|
||||
}
|
||||
|
||||
/**
|
||||
* 생성자
|
||||
*/
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
/**
|
||||
* 수정자
|
||||
*/
|
||||
public function updater(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'updated_by');
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// 스코프
|
||||
// =========================================================================
|
||||
|
||||
/**
|
||||
* 특정 상태 필터
|
||||
*/
|
||||
public function scopeWithStatus($query, string $status)
|
||||
{
|
||||
return $query->where('status', $status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 승인 대기 중
|
||||
*/
|
||||
public function scopePending($query)
|
||||
{
|
||||
return $query->where('status', self::STATUS_PENDING);
|
||||
}
|
||||
|
||||
/**
|
||||
* 승인됨
|
||||
*/
|
||||
public function scopeApproved($query)
|
||||
{
|
||||
return $query->where('status', self::STATUS_APPROVED);
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 기간 내
|
||||
*/
|
||||
public function scopeBetweenDates($query, string $startDate, string $endDate)
|
||||
{
|
||||
return $query->where(function ($q) use ($startDate, $endDate) {
|
||||
$q->whereBetween('start_date', [$startDate, $endDate])
|
||||
->orWhereBetween('end_date', [$startDate, $endDate])
|
||||
->orWhere(function ($q2) use ($startDate, $endDate) {
|
||||
$q2->where('start_date', '<=', $startDate)
|
||||
->where('end_date', '>=', $endDate);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 사용자
|
||||
*/
|
||||
public function scopeForUser($query, int $userId)
|
||||
{
|
||||
return $query->where('user_id', $userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 연도
|
||||
*/
|
||||
public function scopeForYear($query, int $year)
|
||||
{
|
||||
return $query->whereYear('start_date', $year);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// 헬퍼 메서드
|
||||
// =========================================================================
|
||||
|
||||
/**
|
||||
* 수정 가능 여부
|
||||
*/
|
||||
public function isEditable(): bool
|
||||
{
|
||||
return $this->status === self::STATUS_PENDING;
|
||||
}
|
||||
|
||||
/**
|
||||
* 승인 가능 여부
|
||||
*/
|
||||
public function isApprovable(): bool
|
||||
{
|
||||
return $this->status === self::STATUS_PENDING;
|
||||
}
|
||||
|
||||
/**
|
||||
* 취소 가능 여부
|
||||
*/
|
||||
public function isCancellable(): bool
|
||||
{
|
||||
return in_array($this->status, [self::STATUS_PENDING, self::STATUS_APPROVED]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 휴가 유형 라벨
|
||||
*/
|
||||
public function getLeaveTypeLabelAttribute(): string
|
||||
{
|
||||
return match ($this->leave_type) {
|
||||
self::TYPE_ANNUAL => '연차',
|
||||
self::TYPE_HALF_AM => '오전반차',
|
||||
self::TYPE_HALF_PM => '오후반차',
|
||||
self::TYPE_SICK => '병가',
|
||||
self::TYPE_FAMILY => '경조사',
|
||||
self::TYPE_MATERNITY => '출산휴가',
|
||||
self::TYPE_PARENTAL => '육아휴직',
|
||||
default => $this->leave_type,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 상태 라벨
|
||||
*/
|
||||
public function getStatusLabelAttribute(): string
|
||||
{
|
||||
return match ($this->status) {
|
||||
self::STATUS_PENDING => '승인대기',
|
||||
self::STATUS_APPROVED => '승인',
|
||||
self::STATUS_REJECTED => '반려',
|
||||
self::STATUS_CANCELLED => '취소',
|
||||
default => $this->status,
|
||||
};
|
||||
}
|
||||
}
|
||||
111
app/Models/Tenants/LeaveBalance.php
Normal file
111
app/Models/Tenants/LeaveBalance.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Tenants;
|
||||
|
||||
use App\Models\Members\User;
|
||||
use App\Traits\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* 휴가 잔여일수 모델
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $tenant_id
|
||||
* @property int $user_id
|
||||
* @property int $year
|
||||
* @property float $total_days
|
||||
* @property float $used_days
|
||||
* @property float $remaining_days
|
||||
*/
|
||||
class LeaveBalance extends Model
|
||||
{
|
||||
use BelongsToTenant;
|
||||
|
||||
protected $table = 'leave_balances';
|
||||
|
||||
protected $casts = [
|
||||
'year' => 'integer',
|
||||
'total_days' => 'decimal:1',
|
||||
'used_days' => 'decimal:1',
|
||||
'remaining_days' => 'decimal:1',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id',
|
||||
'user_id',
|
||||
'year',
|
||||
'total_days',
|
||||
'used_days',
|
||||
];
|
||||
|
||||
// =========================================================================
|
||||
// 관계 정의
|
||||
// =========================================================================
|
||||
|
||||
/**
|
||||
* 사용자
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// 스코프
|
||||
// =========================================================================
|
||||
|
||||
/**
|
||||
* 특정 연도
|
||||
*/
|
||||
public function scopeForYear($query, int $year)
|
||||
{
|
||||
return $query->where('year', $year);
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 사용자
|
||||
*/
|
||||
public function scopeForUser($query, int $userId)
|
||||
{
|
||||
return $query->where('user_id', $userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 현재 연도
|
||||
*/
|
||||
public function scopeCurrentYear($query)
|
||||
{
|
||||
return $query->where('year', now()->year);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// 헬퍼 메서드
|
||||
// =========================================================================
|
||||
|
||||
/**
|
||||
* 휴가 사용
|
||||
*/
|
||||
public function useLeave(float $days): void
|
||||
{
|
||||
$this->used_days += $days;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* 휴가 복원 (취소 시)
|
||||
*/
|
||||
public function restoreLeave(float $days): void
|
||||
{
|
||||
$this->used_days = max(0, $this->used_days - $days);
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* 사용 가능 여부
|
||||
*/
|
||||
public function canUse(float $days): bool
|
||||
{
|
||||
return $this->remaining_days >= $days;
|
||||
}
|
||||
}
|
||||
385
app/Services/LeaveService.php
Normal file
385
app/Services/LeaveService.php
Normal file
@@ -0,0 +1,385 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Tenants\Leave;
|
||||
use App\Models\Tenants\LeaveBalance;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
class LeaveService extends Service
|
||||
{
|
||||
/**
|
||||
* 휴가 목록 조회
|
||||
*/
|
||||
public function index(array $params): LengthAwarePaginator
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
|
||||
$query = Leave::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->with(['user:id,name,email', 'approver:id,name']);
|
||||
|
||||
// 사용자 필터
|
||||
if (! empty($params['user_id'])) {
|
||||
$query->where('user_id', $params['user_id']);
|
||||
}
|
||||
|
||||
// 상태 필터
|
||||
if (! empty($params['status'])) {
|
||||
$query->where('status', $params['status']);
|
||||
}
|
||||
|
||||
// 휴가 유형 필터
|
||||
if (! empty($params['leave_type'])) {
|
||||
$query->where('leave_type', $params['leave_type']);
|
||||
}
|
||||
|
||||
// 날짜 범위 필터
|
||||
if (! empty($params['date_from'])) {
|
||||
$query->where('start_date', '>=', $params['date_from']);
|
||||
}
|
||||
if (! empty($params['date_to'])) {
|
||||
$query->where('end_date', '<=', $params['date_to']);
|
||||
}
|
||||
|
||||
// 연도 필터
|
||||
if (! empty($params['year'])) {
|
||||
$query->whereYear('start_date', $params['year']);
|
||||
}
|
||||
|
||||
// 부서 필터
|
||||
if (! empty($params['department_id'])) {
|
||||
$query->whereHas('user.tenantProfile', function ($q) use ($params) {
|
||||
$q->where('department_id', $params['department_id']);
|
||||
});
|
||||
}
|
||||
|
||||
// 정렬
|
||||
$sortBy = $params['sort_by'] ?? 'created_at';
|
||||
$sortDir = $params['sort_dir'] ?? 'desc';
|
||||
$query->orderBy($sortBy, $sortDir);
|
||||
|
||||
// 페이지네이션
|
||||
$perPage = $params['per_page'] ?? 20;
|
||||
|
||||
return $query->paginate($perPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 휴가 상세 조회
|
||||
*/
|
||||
public function show(int $id): Leave
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
|
||||
return Leave::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->with(['user:id,name,email', 'approver:id,name'])
|
||||
->findOrFail($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 휴가 신청
|
||||
*/
|
||||
public function store(array $data): Leave
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
$userId = $this->apiUserId();
|
||||
|
||||
return DB::transaction(function () use ($data, $tenantId, $userId) {
|
||||
// 신청자 ID (관리자가 대리 신청 가능)
|
||||
$applicantId = $data['user_id'] ?? $userId;
|
||||
|
||||
// 잔여 휴가 확인 (연차/반차만)
|
||||
if (in_array($data['leave_type'], [Leave::TYPE_ANNUAL, Leave::TYPE_HALF_AM, Leave::TYPE_HALF_PM])) {
|
||||
$year = \Carbon\Carbon::parse($data['start_date'])->year;
|
||||
$balance = $this->getOrCreateBalance($tenantId, $applicantId, $year);
|
||||
|
||||
if (! $balance->canUse($data['days'])) {
|
||||
throw new BadRequestHttpException(__('error.leave.insufficient_balance'));
|
||||
}
|
||||
}
|
||||
|
||||
// 중복 휴가 확인
|
||||
$overlapping = Leave::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('user_id', $applicantId)
|
||||
->whereIn('status', [Leave::STATUS_PENDING, Leave::STATUS_APPROVED])
|
||||
->where(function ($q) use ($data) {
|
||||
$q->whereBetween('start_date', [$data['start_date'], $data['end_date']])
|
||||
->orWhereBetween('end_date', [$data['start_date'], $data['end_date']])
|
||||
->orWhere(function ($q2) use ($data) {
|
||||
$q2->where('start_date', '<=', $data['start_date'])
|
||||
->where('end_date', '>=', $data['end_date']);
|
||||
});
|
||||
})
|
||||
->exists();
|
||||
|
||||
if ($overlapping) {
|
||||
throw new BadRequestHttpException(__('error.leave.overlapping'));
|
||||
}
|
||||
|
||||
$leave = Leave::create([
|
||||
'tenant_id' => $tenantId,
|
||||
'user_id' => $applicantId,
|
||||
'leave_type' => $data['leave_type'],
|
||||
'start_date' => $data['start_date'],
|
||||
'end_date' => $data['end_date'],
|
||||
'days' => $data['days'],
|
||||
'reason' => $data['reason'] ?? null,
|
||||
'status' => Leave::STATUS_PENDING,
|
||||
'created_by' => $userId,
|
||||
'updated_by' => $userId,
|
||||
]);
|
||||
|
||||
return $leave->fresh(['user:id,name,email']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 휴가 수정 (pending 상태만)
|
||||
*/
|
||||
public function update(int $id, array $data): Leave
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
$userId = $this->apiUserId();
|
||||
|
||||
return DB::transaction(function () use ($id, $data, $tenantId, $userId) {
|
||||
$leave = Leave::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->findOrFail($id);
|
||||
|
||||
if (! $leave->isEditable()) {
|
||||
throw new BadRequestHttpException(__('error.leave.not_editable'));
|
||||
}
|
||||
|
||||
// 휴가 기간이 변경된 경우 잔여 휴가 확인
|
||||
if (isset($data['days']) && in_array($leave->leave_type, [Leave::TYPE_ANNUAL, Leave::TYPE_HALF_AM, Leave::TYPE_HALF_PM])) {
|
||||
$year = \Carbon\Carbon::parse($data['start_date'] ?? $leave->start_date)->year;
|
||||
$balance = $this->getOrCreateBalance($tenantId, $leave->user_id, $year);
|
||||
|
||||
if (! $balance->canUse($data['days'])) {
|
||||
throw new BadRequestHttpException(__('error.leave.insufficient_balance'));
|
||||
}
|
||||
}
|
||||
|
||||
$leave->fill([
|
||||
'leave_type' => $data['leave_type'] ?? $leave->leave_type,
|
||||
'start_date' => $data['start_date'] ?? $leave->start_date,
|
||||
'end_date' => $data['end_date'] ?? $leave->end_date,
|
||||
'days' => $data['days'] ?? $leave->days,
|
||||
'reason' => $data['reason'] ?? $leave->reason,
|
||||
'updated_by' => $userId,
|
||||
]);
|
||||
|
||||
$leave->save();
|
||||
|
||||
return $leave->fresh(['user:id,name,email']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 휴가 취소/삭제 (pending 상태만)
|
||||
*/
|
||||
public function destroy(int $id): bool
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
$userId = $this->apiUserId();
|
||||
|
||||
return DB::transaction(function () use ($id, $tenantId, $userId) {
|
||||
$leave = Leave::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->findOrFail($id);
|
||||
|
||||
if (! $leave->isEditable()) {
|
||||
throw new BadRequestHttpException(__('error.leave.not_editable'));
|
||||
}
|
||||
|
||||
$leave->deleted_by = $userId;
|
||||
$leave->save();
|
||||
$leave->delete();
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 휴가 승인
|
||||
*/
|
||||
public function approve(int $id, ?string $comment = null): Leave
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
$userId = $this->apiUserId();
|
||||
|
||||
return DB::transaction(function () use ($id, $tenantId, $userId) {
|
||||
$leave = Leave::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->findOrFail($id);
|
||||
|
||||
if (! $leave->isApprovable()) {
|
||||
throw new BadRequestHttpException(__('error.leave.not_approvable'));
|
||||
}
|
||||
|
||||
// 잔여 휴가 차감 (연차/반차만)
|
||||
if (in_array($leave->leave_type, [Leave::TYPE_ANNUAL, Leave::TYPE_HALF_AM, Leave::TYPE_HALF_PM])) {
|
||||
$year = \Carbon\Carbon::parse($leave->start_date)->year;
|
||||
$balance = $this->getOrCreateBalance($tenantId, $leave->user_id, $year);
|
||||
|
||||
if (! $balance->canUse($leave->days)) {
|
||||
throw new BadRequestHttpException(__('error.leave.insufficient_balance'));
|
||||
}
|
||||
|
||||
$balance->useLeave($leave->days);
|
||||
}
|
||||
|
||||
$leave->status = Leave::STATUS_APPROVED;
|
||||
$leave->approved_by = $userId;
|
||||
$leave->approved_at = now();
|
||||
$leave->updated_by = $userId;
|
||||
$leave->save();
|
||||
|
||||
return $leave->fresh(['user:id,name,email', 'approver:id,name']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 휴가 반려
|
||||
*/
|
||||
public function reject(int $id, string $reason): Leave
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
$userId = $this->apiUserId();
|
||||
|
||||
return DB::transaction(function () use ($id, $reason, $tenantId, $userId) {
|
||||
$leave = Leave::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->findOrFail($id);
|
||||
|
||||
if (! $leave->isApprovable()) {
|
||||
throw new BadRequestHttpException(__('error.leave.not_approvable'));
|
||||
}
|
||||
|
||||
$leave->status = Leave::STATUS_REJECTED;
|
||||
$leave->approved_by = $userId;
|
||||
$leave->approved_at = now();
|
||||
$leave->reject_reason = $reason;
|
||||
$leave->updated_by = $userId;
|
||||
$leave->save();
|
||||
|
||||
return $leave->fresh(['user:id,name,email', 'approver:id,name']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 승인된 휴가 취소 (휴가 복원)
|
||||
*/
|
||||
public function cancel(int $id, ?string $reason = null): Leave
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
$userId = $this->apiUserId();
|
||||
|
||||
return DB::transaction(function () use ($id, $reason, $tenantId, $userId) {
|
||||
$leave = Leave::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->findOrFail($id);
|
||||
|
||||
if (! $leave->isCancellable()) {
|
||||
throw new BadRequestHttpException(__('error.leave.not_cancellable'));
|
||||
}
|
||||
|
||||
// 이미 승인된 휴가라면 잔여일수 복원
|
||||
if ($leave->status === Leave::STATUS_APPROVED) {
|
||||
if (in_array($leave->leave_type, [Leave::TYPE_ANNUAL, Leave::TYPE_HALF_AM, Leave::TYPE_HALF_PM])) {
|
||||
$year = \Carbon\Carbon::parse($leave->start_date)->year;
|
||||
$balance = $this->getOrCreateBalance($tenantId, $leave->user_id, $year);
|
||||
$balance->restoreLeave($leave->days);
|
||||
}
|
||||
}
|
||||
|
||||
$leave->status = Leave::STATUS_CANCELLED;
|
||||
$leave->reject_reason = $reason;
|
||||
$leave->updated_by = $userId;
|
||||
$leave->save();
|
||||
|
||||
return $leave->fresh(['user:id,name,email']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 내 잔여 휴가 조회
|
||||
*/
|
||||
public function getMyBalance(?int $year = null): LeaveBalance
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
$userId = $this->apiUserId();
|
||||
$year = $year ?? now()->year;
|
||||
|
||||
return $this->getOrCreateBalance($tenantId, $userId, $year);
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 사용자 잔여 휴가 조회
|
||||
*/
|
||||
public function getUserBalance(int $userId, ?int $year = null): LeaveBalance
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
$year = $year ?? now()->year;
|
||||
|
||||
return $this->getOrCreateBalance($tenantId, $userId, $year);
|
||||
}
|
||||
|
||||
/**
|
||||
* 잔여 휴가 설정
|
||||
*/
|
||||
public function setBalance(int $userId, int $year, float $totalDays): LeaveBalance
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
|
||||
$balance = LeaveBalance::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('user_id', $userId)
|
||||
->where('year', $year)
|
||||
->first();
|
||||
|
||||
if ($balance) {
|
||||
$balance->total_days = $totalDays;
|
||||
$balance->save();
|
||||
} else {
|
||||
$balance = LeaveBalance::create([
|
||||
'tenant_id' => $tenantId,
|
||||
'user_id' => $userId,
|
||||
'year' => $year,
|
||||
'total_days' => $totalDays,
|
||||
'used_days' => 0,
|
||||
]);
|
||||
}
|
||||
|
||||
return $balance->fresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* 잔여 휴가 조회 또는 생성
|
||||
*/
|
||||
private function getOrCreateBalance(int $tenantId, int $userId, int $year): LeaveBalance
|
||||
{
|
||||
$balance = LeaveBalance::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('user_id', $userId)
|
||||
->where('year', $year)
|
||||
->first();
|
||||
|
||||
if (! $balance) {
|
||||
$balance = LeaveBalance::create([
|
||||
'tenant_id' => $tenantId,
|
||||
'user_id' => $userId,
|
||||
'year' => $year,
|
||||
'total_days' => 15, // 기본 연차 15일
|
||||
'used_days' => 0,
|
||||
]);
|
||||
}
|
||||
|
||||
return $balance;
|
||||
}
|
||||
}
|
||||
493
app/Swagger/v1/LeaveApi.php
Normal file
493
app/Swagger/v1/LeaveApi.php
Normal file
@@ -0,0 +1,493 @@
|
||||
<?php
|
||||
|
||||
namespace App\Swagger\v1;
|
||||
|
||||
/**
|
||||
* @OA\Tag(name="Leaves", description="휴가 관리 (HR)")
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="Leave",
|
||||
* type="object",
|
||||
* description="휴가 정보",
|
||||
*
|
||||
* @OA\Property(property="id", type="integer", example=1, description="휴가 ID"),
|
||||
* @OA\Property(property="tenant_id", type="integer", example=1, description="테넌트 ID"),
|
||||
* @OA\Property(property="user_id", type="integer", example=10, description="신청자 ID"),
|
||||
* @OA\Property(property="leave_type", type="string", enum={"annual","half_am","half_pm","sick","family","maternity","parental"}, example="annual", description="휴가 유형"),
|
||||
* @OA\Property(property="start_date", type="string", format="date", example="2024-01-15", description="시작일"),
|
||||
* @OA\Property(property="end_date", type="string", format="date", example="2024-01-17", description="종료일"),
|
||||
* @OA\Property(property="days", type="number", format="float", example=3.0, description="사용일수"),
|
||||
* @OA\Property(property="reason", type="string", example="개인 사유", nullable=true, description="휴가 사유"),
|
||||
* @OA\Property(property="status", type="string", enum={"pending","approved","rejected","cancelled"}, example="pending", description="상태"),
|
||||
* @OA\Property(property="approved_by", type="integer", example=5, nullable=true, description="승인자 ID"),
|
||||
* @OA\Property(property="approved_at", type="string", format="date-time", example="2024-01-14T10:00:00Z", nullable=true, description="승인/반려 일시"),
|
||||
* @OA\Property(property="reject_reason", type="string", example="인원 부족", nullable=true, description="반려 사유"),
|
||||
* @OA\Property(property="user", type="object", nullable=true, description="신청자 정보",
|
||||
* @OA\Property(property="id", type="integer", example=10),
|
||||
* @OA\Property(property="name", type="string", example="홍길동"),
|
||||
* @OA\Property(property="email", type="string", example="hong@company.com")
|
||||
* ),
|
||||
* @OA\Property(property="approver", type="object", nullable=true, description="승인자 정보",
|
||||
* @OA\Property(property="id", type="integer", example=5),
|
||||
* @OA\Property(property="name", type="string", example="김부장")
|
||||
* ),
|
||||
* @OA\Property(property="created_at", type="string", format="date-time", example="2024-01-13T09:00:00Z"),
|
||||
* @OA\Property(property="updated_at", type="string", format="date-time", example="2024-01-14T10:00:00Z")
|
||||
* )
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="LeaveCreateRequest",
|
||||
* type="object",
|
||||
* required={"leave_type", "start_date", "end_date", "days"},
|
||||
* description="휴가 신청 요청",
|
||||
*
|
||||
* @OA\Property(property="leave_type", type="string", enum={"annual","half_am","half_pm","sick","family","maternity","parental"}, example="annual", description="휴가 유형"),
|
||||
* @OA\Property(property="start_date", type="string", format="date", example="2024-01-15", description="시작일"),
|
||||
* @OA\Property(property="end_date", type="string", format="date", example="2024-01-17", description="종료일"),
|
||||
* @OA\Property(property="days", type="number", format="float", example=3.0, minimum=0.5, maximum=365, description="사용일수"),
|
||||
* @OA\Property(property="reason", type="string", example="개인 사유", description="휴가 사유")
|
||||
* )
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="LeaveUpdateRequest",
|
||||
* type="object",
|
||||
* description="휴가 수정 요청",
|
||||
*
|
||||
* @OA\Property(property="leave_type", type="string", enum={"annual","half_am","half_pm","sick","family","maternity","parental"}, example="annual", description="휴가 유형"),
|
||||
* @OA\Property(property="start_date", type="string", format="date", example="2024-01-15", description="시작일"),
|
||||
* @OA\Property(property="end_date", type="string", format="date", example="2024-01-17", description="종료일"),
|
||||
* @OA\Property(property="days", type="number", format="float", example=3.0, description="사용일수"),
|
||||
* @OA\Property(property="reason", type="string", example="개인 사유", description="휴가 사유")
|
||||
* )
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="LeaveBalance",
|
||||
* type="object",
|
||||
* description="휴가 잔여일수 정보",
|
||||
*
|
||||
* @OA\Property(property="id", type="integer", example=1, description="ID"),
|
||||
* @OA\Property(property="tenant_id", type="integer", example=1, description="테넌트 ID"),
|
||||
* @OA\Property(property="user_id", type="integer", example=10, description="사용자 ID"),
|
||||
* @OA\Property(property="year", type="integer", example=2024, description="연도"),
|
||||
* @OA\Property(property="total_days", type="number", format="float", example=15.0, description="연간 부여일수"),
|
||||
* @OA\Property(property="used_days", type="number", format="float", example=5.0, description="사용일수"),
|
||||
* @OA\Property(property="remaining_days", type="number", format="float", example=10.0, description="잔여일수"),
|
||||
* @OA\Property(property="user", type="object", nullable=true, description="사용자 정보",
|
||||
* @OA\Property(property="id", type="integer", example=10),
|
||||
* @OA\Property(property="name", type="string", example="홍길동")
|
||||
* )
|
||||
* )
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="LeaveBalanceSetRequest",
|
||||
* type="object",
|
||||
* required={"user_id", "year", "total_days"},
|
||||
* description="휴가 잔여일수 설정 요청",
|
||||
*
|
||||
* @OA\Property(property="user_id", type="integer", example=10, description="사용자 ID"),
|
||||
* @OA\Property(property="year", type="integer", example=2024, minimum=2020, maximum=2099, description="연도"),
|
||||
* @OA\Property(property="total_days", type="number", format="float", example=15.0, minimum=0, maximum=365, description="연간 부여일수")
|
||||
* )
|
||||
*/
|
||||
class LeaveApi
|
||||
{
|
||||
/**
|
||||
* @OA\Get(
|
||||
* path="/api/v1/leaves",
|
||||
* tags={"Leaves"},
|
||||
* summary="휴가 목록 조회",
|
||||
* description="필터/검색/페이지네이션으로 휴가 목록을 조회합니다.",
|
||||
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
||||
*
|
||||
* @OA\Parameter(name="user_id", in="query", description="사용자 ID 필터", @OA\Schema(type="integer")),
|
||||
* @OA\Parameter(name="status", in="query", description="상태 필터", @OA\Schema(type="string", enum={"pending","approved","rejected","cancelled"})),
|
||||
* @OA\Parameter(name="leave_type", in="query", description="휴가 유형 필터", @OA\Schema(type="string", enum={"annual","half_am","half_pm","sick","family","maternity","parental"})),
|
||||
* @OA\Parameter(name="date_from", in="query", description="시작일 이후", @OA\Schema(type="string", format="date")),
|
||||
* @OA\Parameter(name="date_to", in="query", description="종료일 이전", @OA\Schema(type="string", format="date")),
|
||||
* @OA\Parameter(name="year", in="query", description="연도 필터", @OA\Schema(type="integer")),
|
||||
* @OA\Parameter(name="sort_by", in="query", description="정렬 기준", @OA\Schema(type="string", enum={"start_date","created_at","status"}, default="start_date")),
|
||||
* @OA\Parameter(name="sort_dir", in="query", description="정렬 방향", @OA\Schema(type="string", enum={"asc","desc"}, default="desc")),
|
||||
* @OA\Parameter(ref="#/components/parameters/Page"),
|
||||
* @OA\Parameter(ref="#/components/parameters/Size"),
|
||||
*
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="조회 성공",
|
||||
*
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
*
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(
|
||||
*
|
||||
* @OA\Property(
|
||||
* property="data",
|
||||
* type="object",
|
||||
* @OA\Property(property="current_page", type="integer", example=1),
|
||||
* @OA\Property(property="data", type="array", @OA\Items(ref="#/components/schemas/Leave")),
|
||||
* @OA\Property(property="per_page", type="integer", example=20),
|
||||
* @OA\Property(property="total", type="integer", example=50)
|
||||
* )
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
*
|
||||
* @OA\Response(response=400, description="잘못된 요청", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
|
||||
* )
|
||||
*/
|
||||
public function index() {}
|
||||
|
||||
/**
|
||||
* @OA\Get(
|
||||
* path="/api/v1/leaves/{id}",
|
||||
* tags={"Leaves"},
|
||||
* summary="휴가 상세 조회",
|
||||
* description="ID 기준 휴가 상세 정보를 조회합니다.",
|
||||
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
||||
*
|
||||
* @OA\Parameter(name="id", in="path", required=true, description="휴가 ID", @OA\Schema(type="integer", example=1)),
|
||||
*
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="조회 성공",
|
||||
*
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
*
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/Leave"))
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
*
|
||||
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=404, description="휴가를 찾을 수 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
|
||||
* )
|
||||
*/
|
||||
public function show() {}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/api/v1/leaves",
|
||||
* tags={"Leaves"},
|
||||
* summary="휴가 신청",
|
||||
* description="새 휴가를 신청합니다. 잔여일수를 초과하거나 기간이 중복되면 실패합니다.",
|
||||
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
||||
*
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
*
|
||||
* @OA\JsonContent(ref="#/components/schemas/LeaveCreateRequest")
|
||||
* ),
|
||||
*
|
||||
* @OA\Response(
|
||||
* response=201,
|
||||
* description="신청 성공",
|
||||
*
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
*
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/Leave"))
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
*
|
||||
* @OA\Response(response=400, description="잘못된 요청 (잔여일수 부족, 기간 중복 등)", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
|
||||
* )
|
||||
*/
|
||||
public function store() {}
|
||||
|
||||
/**
|
||||
* @OA\Patch(
|
||||
* path="/api/v1/leaves/{id}",
|
||||
* tags={"Leaves"},
|
||||
* summary="휴가 수정",
|
||||
* description="대기 상태의 휴가만 수정 가능합니다.",
|
||||
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
||||
*
|
||||
* @OA\Parameter(name="id", in="path", required=true, description="휴가 ID", @OA\Schema(type="integer")),
|
||||
*
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
*
|
||||
* @OA\JsonContent(ref="#/components/schemas/LeaveUpdateRequest")
|
||||
* ),
|
||||
*
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="수정 성공",
|
||||
*
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
*
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/Leave"))
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
*
|
||||
* @OA\Response(response=400, description="잘못된 요청 (수정 불가 상태)", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=404, description="휴가를 찾을 수 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
|
||||
* )
|
||||
*/
|
||||
public function update() {}
|
||||
|
||||
/**
|
||||
* @OA\Delete(
|
||||
* path="/api/v1/leaves/{id}",
|
||||
* tags={"Leaves"},
|
||||
* summary="휴가 삭제",
|
||||
* description="대기 상태의 휴가만 삭제 가능합니다 (소프트 삭제).",
|
||||
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
||||
*
|
||||
* @OA\Parameter(name="id", in="path", required=true, description="휴가 ID", @OA\Schema(type="integer")),
|
||||
*
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="삭제 성공",
|
||||
*
|
||||
* @OA\JsonContent(
|
||||
*
|
||||
* @OA\Property(property="success", type="boolean", example=true),
|
||||
* @OA\Property(property="message", type="string", example="삭제 완료"),
|
||||
* @OA\Property(property="data", type="boolean", example=true)
|
||||
* )
|
||||
* ),
|
||||
*
|
||||
* @OA\Response(response=400, description="잘못된 요청 (삭제 불가 상태)", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=404, description="휴가를 찾을 수 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
|
||||
* )
|
||||
*/
|
||||
public function destroy() {}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/api/v1/leaves/{id}/approve",
|
||||
* tags={"Leaves"},
|
||||
* summary="휴가 승인",
|
||||
* description="대기 상태의 휴가를 승인합니다. 승인 시 잔여일수가 차감됩니다.",
|
||||
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
||||
*
|
||||
* @OA\Parameter(name="id", in="path", required=true, description="휴가 ID", @OA\Schema(type="integer")),
|
||||
*
|
||||
* @OA\RequestBody(
|
||||
* required=false,
|
||||
*
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
*
|
||||
* @OA\Property(property="comment", type="string", example="승인합니다.", description="승인 코멘트")
|
||||
* )
|
||||
* ),
|
||||
*
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="승인 성공",
|
||||
*
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
*
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/Leave"))
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
*
|
||||
* @OA\Response(response=400, description="잘못된 요청 (승인 불가 상태)", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=404, description="휴가를 찾을 수 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
|
||||
* )
|
||||
*/
|
||||
public function approve() {}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/api/v1/leaves/{id}/reject",
|
||||
* tags={"Leaves"},
|
||||
* summary="휴가 반려",
|
||||
* description="대기 상태의 휴가를 반려합니다.",
|
||||
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
||||
*
|
||||
* @OA\Parameter(name="id", in="path", required=true, description="휴가 ID", @OA\Schema(type="integer")),
|
||||
*
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
*
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* required={"reason"},
|
||||
*
|
||||
* @OA\Property(property="reason", type="string", example="인원 부족으로 반려합니다.", description="반려 사유")
|
||||
* )
|
||||
* ),
|
||||
*
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="반려 성공",
|
||||
*
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
*
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/Leave"))
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
*
|
||||
* @OA\Response(response=400, description="잘못된 요청 (반려 불가 상태)", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=404, description="휴가를 찾을 수 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
|
||||
* )
|
||||
*/
|
||||
public function reject() {}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/api/v1/leaves/{id}/cancel",
|
||||
* tags={"Leaves"},
|
||||
* summary="휴가 취소",
|
||||
* description="승인된 휴가를 취소합니다. 취소 시 잔여일수가 복구됩니다.",
|
||||
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
||||
*
|
||||
* @OA\Parameter(name="id", in="path", required=true, description="휴가 ID", @OA\Schema(type="integer")),
|
||||
*
|
||||
* @OA\RequestBody(
|
||||
* required=false,
|
||||
*
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
*
|
||||
* @OA\Property(property="reason", type="string", example="일정 변경으로 취소합니다.", description="취소 사유")
|
||||
* )
|
||||
* ),
|
||||
*
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="취소 성공",
|
||||
*
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
*
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/Leave"))
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
*
|
||||
* @OA\Response(response=400, description="잘못된 요청 (취소 불가 상태)", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=404, description="휴가를 찾을 수 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
|
||||
* )
|
||||
*/
|
||||
public function cancel() {}
|
||||
|
||||
/**
|
||||
* @OA\Get(
|
||||
* path="/api/v1/leaves/balance",
|
||||
* tags={"Leaves"},
|
||||
* summary="내 잔여 휴가 조회",
|
||||
* description="로그인한 사용자의 잔여 휴가를 조회합니다.",
|
||||
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
||||
*
|
||||
* @OA\Parameter(name="year", in="query", description="연도 (미지정시 현재 연도)", @OA\Schema(type="integer", example=2024)),
|
||||
*
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="조회 성공",
|
||||
*
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
*
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/LeaveBalance"))
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
*
|
||||
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
|
||||
* )
|
||||
*/
|
||||
public function balance() {}
|
||||
|
||||
/**
|
||||
* @OA\Get(
|
||||
* path="/api/v1/leaves/balance/{userId}",
|
||||
* tags={"Leaves"},
|
||||
* summary="특정 사용자 잔여 휴가 조회",
|
||||
* description="특정 사용자의 잔여 휴가를 조회합니다 (관리자 전용).",
|
||||
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
||||
*
|
||||
* @OA\Parameter(name="userId", in="path", required=true, description="사용자 ID", @OA\Schema(type="integer", example=10)),
|
||||
* @OA\Parameter(name="year", in="query", description="연도 (미지정시 현재 연도)", @OA\Schema(type="integer", example=2024)),
|
||||
*
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="조회 성공",
|
||||
*
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
*
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/LeaveBalance"))
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
*
|
||||
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=403, description="권한 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=404, description="사용자를 찾을 수 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
|
||||
* )
|
||||
*/
|
||||
public function userBalance() {}
|
||||
|
||||
/**
|
||||
* @OA\Put(
|
||||
* path="/api/v1/leaves/balance",
|
||||
* tags={"Leaves"},
|
||||
* summary="잔여 휴가 설정",
|
||||
* description="특정 사용자의 연간 휴가일수를 설정합니다 (관리자 전용).",
|
||||
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
||||
*
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
*
|
||||
* @OA\JsonContent(ref="#/components/schemas/LeaveBalanceSetRequest")
|
||||
* ),
|
||||
*
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="설정 성공",
|
||||
*
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
*
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/LeaveBalance"))
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
*
|
||||
* @OA\Response(response=400, description="잘못된 요청", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=403, description="권한 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
||||
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
|
||||
* )
|
||||
*/
|
||||
public function setBalance() {}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('leaves', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('tenant_id')->comment('테넌트 ID');
|
||||
$table->unsignedBigInteger('user_id')->comment('신청자 ID');
|
||||
$table->string('leave_type', 20)->comment('휴가유형: annual/half_am/half_pm/sick/family/maternity/parental');
|
||||
$table->date('start_date')->comment('시작일');
|
||||
$table->date('end_date')->comment('종료일');
|
||||
$table->decimal('days', 3, 1)->comment('사용일수');
|
||||
$table->text('reason')->nullable()->comment('휴가 사유');
|
||||
$table->string('status', 20)->default('pending')->comment('상태: pending/approved/rejected/cancelled');
|
||||
$table->unsignedBigInteger('approved_by')->nullable()->comment('승인자 ID');
|
||||
$table->timestamp('approved_at')->nullable()->comment('승인/반려 일시');
|
||||
$table->text('reject_reason')->nullable()->comment('반려 사유');
|
||||
$table->unsignedBigInteger('created_by')->nullable()->comment('등록자');
|
||||
$table->unsignedBigInteger('updated_by')->nullable()->comment('수정자');
|
||||
$table->unsignedBigInteger('deleted_by')->nullable()->comment('삭제자');
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['tenant_id', 'user_id'], 'idx_tenant_user');
|
||||
$table->index('status', 'idx_status');
|
||||
$table->index(['start_date', 'end_date'], 'idx_dates');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('leaves');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('leave_balances', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('tenant_id')->comment('테넌트 ID');
|
||||
$table->unsignedBigInteger('user_id')->comment('사용자 ID');
|
||||
$table->unsignedSmallInteger('year')->comment('연도');
|
||||
$table->decimal('total_days', 4, 1)->default(15)->comment('연간 부여일수');
|
||||
$table->decimal('used_days', 4, 1)->default(0)->comment('사용일수');
|
||||
$table->decimal('remaining_days', 4, 1)->storedAs('total_days - used_days')->comment('잔여일수');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['tenant_id', 'user_id', 'year'], 'uk_tenant_user_year');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('leave_balances');
|
||||
}
|
||||
};
|
||||
@@ -152,4 +152,15 @@
|
||||
'formula_parentheses_mismatch' => '괄호가 올바르게 닫히지 않았습니다.',
|
||||
'formula_unsupported_function' => '지원하지 않는 함수입니다: :function',
|
||||
'formula_calculation_error' => '계산 오류: :expression',
|
||||
|
||||
// 휴가 관리 관련
|
||||
'leave' => [
|
||||
'not_found' => '휴가 정보를 찾을 수 없습니다.',
|
||||
'not_editable' => '대기 상태의 휴가만 수정할 수 있습니다.',
|
||||
'not_approvable' => '대기 상태의 휴가만 승인/반려할 수 있습니다.',
|
||||
'not_cancellable' => '승인된 휴가만 취소할 수 있습니다.',
|
||||
'insufficient_balance' => '잔여 휴가일수가 부족합니다.',
|
||||
'overlapping' => '해당 기간에 이미 신청된 휴가가 있습니다.',
|
||||
'balance_not_found' => '휴가 잔여일수 정보를 찾을 수 없습니다.',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -196,4 +196,17 @@
|
||||
],
|
||||
'quote_email_sent' => '견적서가 이메일로 발송되었습니다.',
|
||||
'quote_kakao_sent' => '견적서가 카카오톡으로 발송되었습니다.',
|
||||
|
||||
// 휴가 관리
|
||||
'leave' => [
|
||||
'fetched' => '휴가를 조회했습니다.',
|
||||
'created' => '휴가가 신청되었습니다.',
|
||||
'updated' => '휴가가 수정되었습니다.',
|
||||
'deleted' => '휴가가 삭제되었습니다.',
|
||||
'approved' => '휴가가 승인되었습니다.',
|
||||
'rejected' => '휴가가 반려되었습니다.',
|
||||
'cancelled' => '휴가가 취소되었습니다.',
|
||||
'balance_fetched' => '잔여 휴가를 조회했습니다.',
|
||||
'balance_updated' => '휴가 일수가 설정되었습니다.',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
use App\Http\Controllers\Api\V1\EstimateController;
|
||||
use App\Http\Controllers\Api\V1\FileStorageController;
|
||||
use App\Http\Controllers\Api\V1\FolderController;
|
||||
use App\Http\Controllers\Api\V1\LeaveController;
|
||||
use App\Http\Controllers\Api\V1\ItemMaster\CustomTabController;
|
||||
use App\Http\Controllers\Api\V1\ItemMaster\EntityRelationshipController;
|
||||
use App\Http\Controllers\Api\V1\ItemMaster\ItemBomItemController;
|
||||
@@ -241,6 +242,21 @@
|
||||
Route::post('/bulk-delete', [AttendanceController::class, 'bulkDelete'])->name('v1.attendances.bulkDelete');
|
||||
});
|
||||
|
||||
// Leave API (휴가 관리)
|
||||
Route::prefix('leaves')->group(function () {
|
||||
Route::get('', [LeaveController::class, 'index'])->name('v1.leaves.index');
|
||||
Route::post('', [LeaveController::class, 'store'])->name('v1.leaves.store');
|
||||
Route::get('/balance', [LeaveController::class, 'balance'])->name('v1.leaves.balance');
|
||||
Route::get('/balance/{userId}', [LeaveController::class, 'userBalance'])->name('v1.leaves.userBalance');
|
||||
Route::put('/balance', [LeaveController::class, 'setBalance'])->name('v1.leaves.setBalance');
|
||||
Route::get('/{id}', [LeaveController::class, 'show'])->name('v1.leaves.show');
|
||||
Route::patch('/{id}', [LeaveController::class, 'update'])->name('v1.leaves.update');
|
||||
Route::delete('/{id}', [LeaveController::class, 'destroy'])->name('v1.leaves.destroy');
|
||||
Route::post('/{id}/approve', [LeaveController::class, 'approve'])->name('v1.leaves.approve');
|
||||
Route::post('/{id}/reject', [LeaveController::class, 'reject'])->name('v1.leaves.reject');
|
||||
Route::post('/{id}/cancel', [LeaveController::class, 'cancel'])->name('v1.leaves.cancel');
|
||||
});
|
||||
|
||||
// Permission API
|
||||
Route::prefix('permissions')->group(function () {
|
||||
Route::get('departments/{dept_id}/menu-matrix', [PermissionController::class, 'deptMenuMatrix'])->name('v1.permissions.deptMenuMatrix'); // 부서별 권한 메트릭스
|
||||
|
||||
Reference in New Issue
Block a user