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-24 08:54:52 +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;
|
|
|
|
|
use App\Http\Requests\V1\Plan\PlanIndexRequest;
|
|
|
|
|
use App\Http\Requests\V1\Plan\PlanStoreRequest;
|
|
|
|
|
use App\Http\Requests\V1\Plan\PlanUpdateRequest;
|
|
|
|
|
use App\Services\PlanService;
|
|
|
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
|
|
|
|
|
|
class PlanController extends Controller
|
|
|
|
|
{
|
|
|
|
|
public function __construct(
|
|
|
|
|
private readonly PlanService $planService
|
|
|
|
|
) {}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 요금제 목록 (관리자용)
|
|
|
|
|
*/
|
|
|
|
|
public function index(PlanIndexRequest $request): JsonResponse
|
|
|
|
|
{
|
2025-12-24 08:54:52 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->planService->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 active(): JsonResponse
|
|
|
|
|
{
|
2025-12-24 08:54:52 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->planService->active(),
|
|
|
|
|
__('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(PlanStoreRequest $request): JsonResponse
|
|
|
|
|
{
|
2025-12-24 08:54:52 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->planService->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-24 08:54:52 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->planService->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 update(PlanUpdateRequest $request, int $id): JsonResponse
|
|
|
|
|
{
|
2025-12-24 08:54:52 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->planService->update($id, $request->validated()),
|
|
|
|
|
__('message.updated')
|
|
|
|
|
);
|
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 destroy(int $id): JsonResponse
|
|
|
|
|
{
|
2025-12-24 08:54:52 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->planService->destroy($id),
|
|
|
|
|
__('message.deleted')
|
|
|
|
|
);
|
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 toggle(int $id): JsonResponse
|
|
|
|
|
{
|
2025-12-24 08:54:52 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->planService->toggle($id),
|
|
|
|
|
__('message.updated')
|
|
|
|
|
);
|
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
|
|
|
}
|
|
|
|
|
}
|