<?php

namespace App\Http\Controllers\Api\V1;

use App\Helpers\ApiResponse;
use App\Http\Controllers\Controller;
use App\Http\Requests\LeavePolicy\UpdateRequest;
use App\Services\LeavePolicyService;
use Illuminate\Http\JsonResponse;

/**
 * 휴가 정책 관리 컨트롤러
 */
class LeavePolicyController extends Controller
{
    public function __construct(
        protected LeavePolicyService $service
    ) {}

    /**
     * 휴가 정책 조회
     * GET /v1/leave-policy
     */
    public function show(): JsonResponse
    {
        return ApiResponse::handle(function () {
            return $this->service->show();
        }, __('message.fetched'));
    }

    /**
     * 휴가 정책 업데이트
     * PUT /v1/leave-policy
     */
    public function update(UpdateRequest $request): JsonResponse
    {
        return ApiResponse::handle(function () use ($request) {
            return $this->service->update($request->validated());
        }, __('message.updated'));
    }
}
