98 lines
2.2 KiB
PHP
98 lines
2.2 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Controllers\Api\V1;
|
||
|
|
|
||
|
|
use App\Http\Controllers\Controller;
|
||
|
|
use App\Http\Requests\V1\Withdrawal\StoreWithdrawalRequest;
|
||
|
|
use App\Http\Requests\V1\Withdrawal\UpdateWithdrawalRequest;
|
||
|
|
use App\Http\Responses\ApiResponse;
|
||
|
|
use App\Services\WithdrawalService;
|
||
|
|
use Illuminate\Http\Request;
|
||
|
|
|
||
|
|
class WithdrawalController extends Controller
|
||
|
|
{
|
||
|
|
public function __construct(
|
||
|
|
private readonly WithdrawalService $service
|
||
|
|
) {}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 출금 목록
|
||
|
|
*/
|
||
|
|
public function index(Request $request)
|
||
|
|
{
|
||
|
|
$params = $request->only([
|
||
|
|
'search',
|
||
|
|
'start_date',
|
||
|
|
'end_date',
|
||
|
|
'client_id',
|
||
|
|
'payment_method',
|
||
|
|
'bank_account_id',
|
||
|
|
'sort_by',
|
||
|
|
'sort_dir',
|
||
|
|
'per_page',
|
||
|
|
'page',
|
||
|
|
]);
|
||
|
|
|
||
|
|
$withdrawals = $this->service->index($params);
|
||
|
|
|
||
|
|
return ApiResponse::handle(__('message.fetched'), $withdrawals);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 출금 등록
|
||
|
|
*/
|
||
|
|
public function store(StoreWithdrawalRequest $request)
|
||
|
|
{
|
||
|
|
$withdrawal = $this->service->store($request->validated());
|
||
|
|
|
||
|
|
return ApiResponse::handle(__('message.created'), $withdrawal, 201);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 출금 상세
|
||
|
|
*/
|
||
|
|
public function show(int $id)
|
||
|
|
{
|
||
|
|
$withdrawal = $this->service->show($id);
|
||
|
|
|
||
|
|
return ApiResponse::handle(__('message.fetched'), $withdrawal);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 출금 수정
|
||
|
|
*/
|
||
|
|
public function update(int $id, UpdateWithdrawalRequest $request)
|
||
|
|
{
|
||
|
|
$withdrawal = $this->service->update($id, $request->validated());
|
||
|
|
|
||
|
|
return ApiResponse::handle(__('message.updated'), $withdrawal);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 출금 삭제
|
||
|
|
*/
|
||
|
|
public function destroy(int $id)
|
||
|
|
{
|
||
|
|
$this->service->destroy($id);
|
||
|
|
|
||
|
|
return ApiResponse::handle(__('message.deleted'));
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 출금 요약 (기간별 합계)
|
||
|
|
*/
|
||
|
|
public function summary(Request $request)
|
||
|
|
{
|
||
|
|
$params = $request->only([
|
||
|
|
'start_date',
|
||
|
|
'end_date',
|
||
|
|
'client_id',
|
||
|
|
'payment_method',
|
||
|
|
]);
|
||
|
|
|
||
|
|
$summary = $this->service->summary($params);
|
||
|
|
|
||
|
|
return ApiResponse::handle(__('message.fetched'), $summary);
|
||
|
|
}
|
||
|
|
}
|