25 lines
1.1 KiB
PHP
25 lines
1.1 KiB
PHP
<?php
|
|
require_once "../../../bootstrap.php";
|
|
|
|
use \Backend\Models\GameData;
|
|
use \Backend\Models\Group;
|
|
use Backend\Models\Registration;
|
|
|
|
if (isset($_GET['gameDataId'])) {
|
|
$openGameDataStream = GameData::find($_GET['gameDataId']);
|
|
} elseif (isset($_GET['registrationId'])) {
|
|
$openGameDataStream = Registration::find($_GET['registrationId']);
|
|
} elseif (isset($_GET['groupId'])) {
|
|
$registrationIds = Registration::where("group_id", $_GET['groupId'])->pluck("game_data_id")->toArray();
|
|
$openGameDataStream = GameData::whereIn("id", $registrationIds)->get();
|
|
} elseif (isset($_GET['gameJamId'])) {
|
|
$gameDataIds = Group::where("game_jam_id", $_GET['gameJamId'])->pluck("game_data_id")->toArray();
|
|
$openGameDataStream = GameData::whereIn("id", $gameDataIds)->get();
|
|
} else {
|
|
$openGameDataStream = GameData::all();
|
|
}
|
|
|
|
header("Access-Control-Allow-Methods: GET");
|
|
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept");
|
|
header('Content-Type: application/json;charset=UTF-8');
|
|
echo json_encode(array('data' => $openGameDataStream->jsonSerialize())); |