44 lines
1.0 KiB
PHP
44 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\Public;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\PublicWinners\PublicWinnersPortalService;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
/**
|
|
* Published competition winners (public JSON).
|
|
*/
|
|
class PublicWinnersController extends Controller
|
|
{
|
|
public function __construct(
|
|
private PublicWinnersPortalService $winners,
|
|
) {}
|
|
|
|
public function competitionIndex(): JsonResponse
|
|
{
|
|
return response()->json([
|
|
'status' => true,
|
|
'data' => [
|
|
'competitions' => $this->winners->publishedCompetitions(),
|
|
],
|
|
]);
|
|
}
|
|
|
|
public function competitionShow(int $id): JsonResponse
|
|
{
|
|
$payload = $this->winners->competitionPayload($id);
|
|
if ($payload === null) {
|
|
return response()->json([
|
|
'status' => false,
|
|
'message' => 'Competition not found.',
|
|
], 404);
|
|
}
|
|
|
|
return response()->json([
|
|
'status' => true,
|
|
'data' => $payload,
|
|
]);
|
|
}
|
|
}
|