- CorporateVehicle 모델 (photos 관계 포함) - VehiclePhotoService (R2 저장, 최대 10장 제한) - VehiclePhotoController (index/store/destroy) - StoreVehiclePhotoRequest (동적 max 검증) - finance.php 라우트 등록
39 lines
1.0 KiB
PHP
39 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\V1;
|
|
|
|
use App\Helpers\ApiResponse;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Finance\StoreVehiclePhotoRequest;
|
|
use App\Services\Finance\VehiclePhotoService;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
class VehiclePhotoController extends Controller
|
|
{
|
|
public function __construct(private readonly VehiclePhotoService $service) {}
|
|
|
|
public function index(int $id): JsonResponse
|
|
{
|
|
return ApiResponse::handle(
|
|
fn () => $this->service->index($id),
|
|
__('message.fetched')
|
|
);
|
|
}
|
|
|
|
public function store(StoreVehiclePhotoRequest $request, int $id): JsonResponse
|
|
{
|
|
return ApiResponse::handle(
|
|
fn () => $this->service->store($id, $request->file('files')),
|
|
__('message.created')
|
|
);
|
|
}
|
|
|
|
public function destroy(int $id, int $fileId): JsonResponse
|
|
{
|
|
return ApiResponse::handle(
|
|
fn () => $this->service->destroy($id, $fileId),
|
|
__('message.deleted')
|
|
);
|
|
}
|
|
}
|