26 lines
574 B
PHP
26 lines
574 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Set\Set;
|
|
use App\Set\UseCases\ListSets\ListSets;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
class SetController extends Controller
|
|
{
|
|
public function __construct(
|
|
private ListSets $listSets,
|
|
) {}
|
|
|
|
public function index(): JsonResponse
|
|
{
|
|
$sets = array_map(function (Set $set): array {
|
|
return [
|
|
'id' => $set->getId(),
|
|
'name' => $set->getName(),
|
|
];
|
|
}, $this->listSets->execute());
|
|
|
|
return new JsonResponse(['sets' => $sets]);
|
|
}
|
|
}
|