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

19 lines
674 B
PHP
Raw Normal View History

2021-03-11 12:20:10 +00:00
<?php
require_once "../../../bootstrap.php";
use \Backend\Models\GameData;
use \Backend\Models\Group;
if(isset($_GET['gameDataId'])){
$openGameDataStream = GameData::find($_GET['gameDataId']);
}elseif(isset($_GET['groupId'])){
$openGameDataStream = Group::find($_GET['groupId'])->GameData();
}elseif (isset($_GET['gameJamId'])){
2021-03-11 13:22:19 +00:00
$gameDataIds = Group::where("game_jam_id",$_GET['gameJamId'])->pluck("game_data_id")->toArray();
$openGameDataStream = GameData::whereIn("id", $gameDataIds)->get();
2021-03-11 12:20:10 +00:00
}else{
$openGameDataStream = GameData::all();
}
header('Content-Type: application/json;charset=UTF-8');
2021-03-12 13:05:31 +00:00
echo $openGameDataStream->toJson(JSON_PRETTY_PRINT);