Game-Jaming/Backend/Controllers/FileHandler/GetGameData.php

22 lines
705 B
PHP

<?php
require_once "../../../bootstrap.php";
use \Backend\Models\GameData;
use \Backend\Models\Group;
use \Backend\Models\GameJam;
if(isset($_GET['gameDataId'])){
$openGameDataStream = GameData::find($_GET['gameDataId']);
}elseif(isset($_GET['groupId'])){
$openGameDataStream = Group::find($_GET['groupId'])->GameData();
}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('Content-Type: application/json;charset=UTF-8');
echo $openGameDataStream->toJson(JSON_PRETTY_PRINT);