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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue