22 lines
570 B
PHP
22 lines
570 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Controllers;
|
||
|
|
||
|
use Illuminate\Http\Request;
|
||
|
use App\Models\CurrentState;
|
||
|
use App\Models\GameSession;
|
||
|
|
||
|
class CurrentStateController extends Controller
|
||
|
{
|
||
|
public function index()
|
||
|
{
|
||
|
$currentGame = GameSession::whereNull('ended_at')->latest()->first();
|
||
|
if (!$currentGame) {
|
||
|
return response()->json(['error' => 'No active game session'], 404);
|
||
|
}
|
||
|
|
||
|
$currentState = CurrentState::where('game_session_id', $currentGame->id)->with('color')->get();
|
||
|
return response()->json($currentState);
|
||
|
}
|
||
|
}
|