add set root ids
This commit is contained in:
parent
a87c98a729
commit
7736b88802
4 changed files with 36 additions and 3 deletions
|
|
@ -2,14 +2,17 @@
|
|||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Element\ElementRepository;
|
||||
use App\Set\Set as DomainSet;
|
||||
use App\Set\SetRepository;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class SetController
|
||||
{
|
||||
public function __construct(private SetRepository $setRepository)
|
||||
{
|
||||
public function __construct(
|
||||
private SetRepository $setRepository,
|
||||
private ElementRepository $elementRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
public function index(): JsonResponse
|
||||
|
|
@ -29,16 +32,20 @@ class SetController
|
|||
* id: int,
|
||||
* name: string,
|
||||
* description: string,
|
||||
* iconImageUrl: string
|
||||
* iconImageUrl: string,
|
||||
* rootElementId: int|null
|
||||
* }
|
||||
*/
|
||||
private function buildSetPayload(DomainSet $set): array
|
||||
{
|
||||
$rootElement = $this->elementRepository->findRootBySet($set);
|
||||
|
||||
return [
|
||||
'id' => $set->getId(),
|
||||
'name' => $set->getName(),
|
||||
'description' => $set->getDescription(),
|
||||
'iconImageUrl' => $set->getIconImageUrl(),
|
||||
'rootElementId' => $rootElement?->getId(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue