add element endpoint
This commit is contained in:
parent
f9c92f3206
commit
90de724f63
2 changed files with 27 additions and 0 deletions
25
backend/app/Controllers/ElementController.php
Normal file
25
backend/app/Controllers/ElementController.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Element\ElementRepository;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class ElementController
|
||||
{
|
||||
public function __construct(private ElementRepository $elementRepository)
|
||||
{
|
||||
}
|
||||
|
||||
public function show(int $id): JsonResponse
|
||||
{
|
||||
$element = $this->elementRepository->find($id);
|
||||
|
||||
return new JsonResponse([
|
||||
'element' => [
|
||||
'id' => $element->getId(),
|
||||
'title' => $element->getTitle(),
|
||||
],
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
use App\Controllers\AuthController;
|
||||
use App\Controllers\ElementController;
|
||||
use App\Controllers\SetController;
|
||||
use App\Http\Middleware\AuthMiddleware;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
|
@ -10,3 +11,4 @@ Route::post('/logout', [AuthController::class, 'logout']);
|
|||
Route::get('/me', [AuthController::class, 'me'])
|
||||
->middleware(AuthMiddleware::class);
|
||||
Route::get('/sets', [SetController::class, 'index']);
|
||||
Route::get('/elements/{id}', [ElementController::class, 'show']);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue