|
@@ -0,0 +1,26 @@
|
|
|
|
|
+<?php
|
|
|
|
|
+
|
|
|
|
|
+namespace App\Http\Controllers;
|
|
|
|
|
+
|
|
|
|
|
+use App\Http\Resources\PositionResource;
|
|
|
|
|
+use App\Services\PositionService;
|
|
|
|
|
+use Illuminate\Http\JsonResponse;
|
|
|
|
|
+
|
|
|
|
|
+class PositionController extends Controller
|
|
|
|
|
+{
|
|
|
|
|
+ public function __construct(
|
|
|
|
|
+ protected PositionService $service,
|
|
|
|
|
+ ) {}
|
|
|
|
|
+
|
|
|
|
|
+ public function index(): JsonResponse
|
|
|
|
|
+ {
|
|
|
|
|
+ $items = $this->service->getAllItems();
|
|
|
|
|
+ return $this->successResponse(payload: PositionResource::collection($items));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function show(int $id): JsonResponse
|
|
|
|
|
+ {
|
|
|
|
|
+ $item = $this->service->getItem($id);
|
|
|
|
|
+ return $this->successResponse(payload: new PositionResource($item));
|
|
|
|
|
+ }
|
|
|
|
|
+}
|