Game-Jaming/Backend/Controllers/Group/GetGroup.php

18 lines
645 B
PHP
Raw Normal View History

2021-03-11 10:13:06 +00:00
<?php
require_once "../../../bootstrap.php";
2021-04-19 07:15:15 +00:00
2021-03-11 10:13:06 +00:00
use Backend\Models\Group;
2021-04-19 07:15:15 +00:00
if (isset($_GET["groupId"])) {
2021-03-19 12:51:25 +00:00
$groups = Group::find($_GET["groupId"]);
2021-04-19 07:15:15 +00:00
} elseif (isset($_GET["gameJameId"])) {
$registrationIds = Registration::where("game_jam_id", $_GET["gameJameId"])->pluck("game_data_id")->toArray();
$groups = Group::whereIn("id", $registrationIds)->get();
} else {
2021-03-11 10:13:06 +00:00
$groups = Group::all();
}
2021-03-19 08:18:19 +00:00
header("Access-Control-Allow-Methods: GET");
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept");
2021-03-11 10:13:06 +00:00
header('Content-Type: application/json;charset=UTF-8');
2021-03-22 14:29:18 +00:00
echo json_encode(array('data' => $groups->jsonSerialize()));