feat: 구독/결제 API 확장 (Plan, Subscription, Payment)
- Plan/Subscription/Payment 모델에 상태 상수, 스코프, 헬퍼 메서드 추가
- PlanService, SubscriptionService, PaymentService 생성
- PlanController, SubscriptionController, PaymentController 생성
- FormRequest 9개 생성 (Plan 3개, Subscription 3개, Payment 3개)
- Swagger 문서 3개 생성 (PlanApi, SubscriptionApi, PaymentApi)
- API 라우트 22개 등록 (Plan 7개, Subscription 8개, Payment 7개)
- Pint 코드 스타일 정리
2025-12-18 16:20:29 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Api\V1;
|
|
|
|
|
|
2025-12-22 17:42:59 +09:00
|
|
|
use App\Helpers\ApiResponse;
|
feat: 구독/결제 API 확장 (Plan, Subscription, Payment)
- Plan/Subscription/Payment 모델에 상태 상수, 스코프, 헬퍼 메서드 추가
- PlanService, SubscriptionService, PaymentService 생성
- PlanController, SubscriptionController, PaymentController 생성
- FormRequest 9개 생성 (Plan 3개, Subscription 3개, Payment 3개)
- Swagger 문서 3개 생성 (PlanApi, SubscriptionApi, PaymentApi)
- API 라우트 22개 등록 (Plan 7개, Subscription 8개, Payment 7개)
- Pint 코드 스타일 정리
2025-12-18 16:20:29 +09:00
|
|
|
use App\Http\Controllers\Controller;
|
2025-12-19 16:53:49 +09:00
|
|
|
use App\Http\Requests\V1\Subscription\ExportStoreRequest;
|
feat: 구독/결제 API 확장 (Plan, Subscription, Payment)
- Plan/Subscription/Payment 모델에 상태 상수, 스코프, 헬퍼 메서드 추가
- PlanService, SubscriptionService, PaymentService 생성
- PlanController, SubscriptionController, PaymentController 생성
- FormRequest 9개 생성 (Plan 3개, Subscription 3개, Payment 3개)
- Swagger 문서 3개 생성 (PlanApi, SubscriptionApi, PaymentApi)
- API 라우트 22개 등록 (Plan 7개, Subscription 8개, Payment 7개)
- Pint 코드 스타일 정리
2025-12-18 16:20:29 +09:00
|
|
|
use App\Http\Requests\V1\Subscription\SubscriptionCancelRequest;
|
|
|
|
|
use App\Http\Requests\V1\Subscription\SubscriptionIndexRequest;
|
|
|
|
|
use App\Http\Requests\V1\Subscription\SubscriptionStoreRequest;
|
|
|
|
|
use App\Services\SubscriptionService;
|
|
|
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
|
|
|
|
|
|
class SubscriptionController extends Controller
|
|
|
|
|
{
|
|
|
|
|
public function __construct(
|
|
|
|
|
private readonly SubscriptionService $subscriptionService
|
|
|
|
|
) {}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 구독 목록
|
|
|
|
|
*/
|
|
|
|
|
public function index(SubscriptionIndexRequest $request): JsonResponse
|
|
|
|
|
{
|
2025-12-22 17:42:59 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->subscriptionService->index($request->validated()),
|
|
|
|
|
__('message.fetched')
|
|
|
|
|
);
|
feat: 구독/결제 API 확장 (Plan, Subscription, Payment)
- Plan/Subscription/Payment 모델에 상태 상수, 스코프, 헬퍼 메서드 추가
- PlanService, SubscriptionService, PaymentService 생성
- PlanController, SubscriptionController, PaymentController 생성
- FormRequest 9개 생성 (Plan 3개, Subscription 3개, Payment 3개)
- Swagger 문서 3개 생성 (PlanApi, SubscriptionApi, PaymentApi)
- API 라우트 22개 등록 (Plan 7개, Subscription 8개, Payment 7개)
- Pint 코드 스타일 정리
2025-12-18 16:20:29 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 현재 활성 구독
|
|
|
|
|
*/
|
|
|
|
|
public function current(): JsonResponse
|
|
|
|
|
{
|
2025-12-22 17:42:59 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->subscriptionService->current(),
|
|
|
|
|
__('message.fetched')
|
|
|
|
|
);
|
feat: 구독/결제 API 확장 (Plan, Subscription, Payment)
- Plan/Subscription/Payment 모델에 상태 상수, 스코프, 헬퍼 메서드 추가
- PlanService, SubscriptionService, PaymentService 생성
- PlanController, SubscriptionController, PaymentController 생성
- FormRequest 9개 생성 (Plan 3개, Subscription 3개, Payment 3개)
- Swagger 문서 3개 생성 (PlanApi, SubscriptionApi, PaymentApi)
- API 라우트 22개 등록 (Plan 7개, Subscription 8개, Payment 7개)
- Pint 코드 스타일 정리
2025-12-18 16:20:29 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 구독 등록
|
|
|
|
|
*/
|
|
|
|
|
public function store(SubscriptionStoreRequest $request): JsonResponse
|
|
|
|
|
{
|
2025-12-22 17:42:59 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->subscriptionService->store($request->validated()),
|
|
|
|
|
__('message.created')
|
|
|
|
|
);
|
feat: 구독/결제 API 확장 (Plan, Subscription, Payment)
- Plan/Subscription/Payment 모델에 상태 상수, 스코프, 헬퍼 메서드 추가
- PlanService, SubscriptionService, PaymentService 생성
- PlanController, SubscriptionController, PaymentController 생성
- FormRequest 9개 생성 (Plan 3개, Subscription 3개, Payment 3개)
- Swagger 문서 3개 생성 (PlanApi, SubscriptionApi, PaymentApi)
- API 라우트 22개 등록 (Plan 7개, Subscription 8개, Payment 7개)
- Pint 코드 스타일 정리
2025-12-18 16:20:29 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 구독 상세
|
|
|
|
|
*/
|
|
|
|
|
public function show(int $id): JsonResponse
|
|
|
|
|
{
|
2025-12-22 17:42:59 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->subscriptionService->show($id),
|
|
|
|
|
__('message.fetched')
|
|
|
|
|
);
|
feat: 구독/결제 API 확장 (Plan, Subscription, Payment)
- Plan/Subscription/Payment 모델에 상태 상수, 스코프, 헬퍼 메서드 추가
- PlanService, SubscriptionService, PaymentService 생성
- PlanController, SubscriptionController, PaymentController 생성
- FormRequest 9개 생성 (Plan 3개, Subscription 3개, Payment 3개)
- Swagger 문서 3개 생성 (PlanApi, SubscriptionApi, PaymentApi)
- API 라우트 22개 등록 (Plan 7개, Subscription 8개, Payment 7개)
- Pint 코드 스타일 정리
2025-12-18 16:20:29 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 구독 취소
|
|
|
|
|
*/
|
|
|
|
|
public function cancel(SubscriptionCancelRequest $request, int $id): JsonResponse
|
|
|
|
|
{
|
2025-12-22 17:42:59 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->subscriptionService->cancel($id, $request->validated()['reason'] ?? null),
|
|
|
|
|
__('message.subscription.cancelled')
|
|
|
|
|
);
|
feat: 구독/결제 API 확장 (Plan, Subscription, Payment)
- Plan/Subscription/Payment 모델에 상태 상수, 스코프, 헬퍼 메서드 추가
- PlanService, SubscriptionService, PaymentService 생성
- PlanController, SubscriptionController, PaymentController 생성
- FormRequest 9개 생성 (Plan 3개, Subscription 3개, Payment 3개)
- Swagger 문서 3개 생성 (PlanApi, SubscriptionApi, PaymentApi)
- API 라우트 22개 등록 (Plan 7개, Subscription 8개, Payment 7개)
- Pint 코드 스타일 정리
2025-12-18 16:20:29 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 구독 갱신
|
|
|
|
|
*/
|
|
|
|
|
public function renew(SubscriptionStoreRequest $request, int $id): JsonResponse
|
|
|
|
|
{
|
2025-12-22 17:42:59 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->subscriptionService->renew($id, $request->validated()),
|
|
|
|
|
__('message.subscription.renewed')
|
|
|
|
|
);
|
feat: 구독/결제 API 확장 (Plan, Subscription, Payment)
- Plan/Subscription/Payment 모델에 상태 상수, 스코프, 헬퍼 메서드 추가
- PlanService, SubscriptionService, PaymentService 생성
- PlanController, SubscriptionController, PaymentController 생성
- FormRequest 9개 생성 (Plan 3개, Subscription 3개, Payment 3개)
- Swagger 문서 3개 생성 (PlanApi, SubscriptionApi, PaymentApi)
- API 라우트 22개 등록 (Plan 7개, Subscription 8개, Payment 7개)
- Pint 코드 스타일 정리
2025-12-18 16:20:29 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 구독 일시정지
|
|
|
|
|
*/
|
|
|
|
|
public function suspend(int $id): JsonResponse
|
|
|
|
|
{
|
2025-12-22 17:42:59 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->subscriptionService->suspend($id),
|
|
|
|
|
__('message.subscription.suspended')
|
|
|
|
|
);
|
feat: 구독/결제 API 확장 (Plan, Subscription, Payment)
- Plan/Subscription/Payment 모델에 상태 상수, 스코프, 헬퍼 메서드 추가
- PlanService, SubscriptionService, PaymentService 생성
- PlanController, SubscriptionController, PaymentController 생성
- FormRequest 9개 생성 (Plan 3개, Subscription 3개, Payment 3개)
- Swagger 문서 3개 생성 (PlanApi, SubscriptionApi, PaymentApi)
- API 라우트 22개 등록 (Plan 7개, Subscription 8개, Payment 7개)
- Pint 코드 스타일 정리
2025-12-18 16:20:29 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 구독 재개
|
|
|
|
|
*/
|
|
|
|
|
public function resume(int $id): JsonResponse
|
|
|
|
|
{
|
2025-12-22 17:42:59 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->subscriptionService->resume($id),
|
|
|
|
|
__('message.subscription.resumed')
|
|
|
|
|
);
|
feat: 구독/결제 API 확장 (Plan, Subscription, Payment)
- Plan/Subscription/Payment 모델에 상태 상수, 스코프, 헬퍼 메서드 추가
- PlanService, SubscriptionService, PaymentService 생성
- PlanController, SubscriptionController, PaymentController 생성
- FormRequest 9개 생성 (Plan 3개, Subscription 3개, Payment 3개)
- Swagger 문서 3개 생성 (PlanApi, SubscriptionApi, PaymentApi)
- API 라우트 22개 등록 (Plan 7개, Subscription 8개, Payment 7개)
- Pint 코드 스타일 정리
2025-12-18 16:20:29 +09:00
|
|
|
}
|
2025-12-19 16:53:49 +09:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 사용량 조회
|
|
|
|
|
*/
|
|
|
|
|
public function usage(): JsonResponse
|
|
|
|
|
{
|
2025-12-22 17:42:59 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->subscriptionService->usage(),
|
|
|
|
|
__('message.fetched')
|
|
|
|
|
);
|
2025-12-19 16:53:49 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 내보내기 요청
|
|
|
|
|
*/
|
|
|
|
|
public function export(ExportStoreRequest $request): JsonResponse
|
|
|
|
|
{
|
2025-12-22 17:42:59 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->subscriptionService->createExport($request->validated()),
|
|
|
|
|
__('message.export.requested')
|
|
|
|
|
);
|
2025-12-19 16:53:49 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 내보내기 상태 조회
|
|
|
|
|
*/
|
|
|
|
|
public function exportStatus(int $id): JsonResponse
|
|
|
|
|
{
|
2025-12-22 17:42:59 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->subscriptionService->getExport($id),
|
|
|
|
|
__('message.fetched')
|
|
|
|
|
);
|
2025-12-19 16:53:49 +09:00
|
|
|
}
|
feat: 구독/결제 API 확장 (Plan, Subscription, Payment)
- Plan/Subscription/Payment 모델에 상태 상수, 스코프, 헬퍼 메서드 추가
- PlanService, SubscriptionService, PaymentService 생성
- PlanController, SubscriptionController, PaymentController 생성
- FormRequest 9개 생성 (Plan 3개, Subscription 3개, Payment 3개)
- Swagger 문서 3개 생성 (PlanApi, SubscriptionApi, PaymentApi)
- API 라우트 22개 등록 (Plan 7개, Subscription 8개, Payment 7개)
- Pint 코드 스타일 정리
2025-12-18 16:20:29 +09:00
|
|
|
}
|