update controllers logic
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user