<?php

namespace App\Http\Controllers\Api\V1;

use App\Helpers\ApiResponse;
use App\Http\Controllers\Controller;
use App\Services\TenantOptionGroupService;
use Illuminate\Http\Request;

class TenantOptionGroupController extends Controller
{
    // GET /v1/opt-groups
    public function index(Request $request)
    {
        return ApiResponse::handle(function () use ($request) {
            return TenantOptionGroupService::index($request->all());
        }, '옵션 그룹 목록 조회');
    }

    // POST /v1/opt-groups
    public function store(Request $request)
    {
        return ApiResponse::handle(function () use ($request) {
            return TenantOptionGroupService::store($request->all());
        }, '옵션 그룹 생성');
    }

    // GET /v1/opt-groups/{id}
    public function show($id)
    {
        return ApiResponse::handle(function () use ($id) {
            return TenantOptionGroupService::show($id);
        }, '옵션 그룹 단건 조회');
    }

    // PATCH /v1/opt-groups/{id}
    public function update(Request $request, $id)
    {
        return ApiResponse::handle(function () use ($request, $id) {
            return TenantOptionGroupService::update($id, $request->all());
        }, '옵션 그룹 수정');
    }

    // DELETE /v1/opt-groups/{id}
    public function destroy($id)
    {
        return ApiResponse::handle(function () use ($id) {
            return TenantOptionGroupService::destroy($id);
        }, '옵션 그룹 삭제');
    }
}
