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

18 lines
535 B
PHP

<?php
require_once "../../../bootstrap.php";
use Backend\Models\Group;
if (isset($_GET["groupId"])){
$groups = Group::find($_GET["groupId"]);
}
elseif(isset($_GET["gameJameId"])){
$groups = Group::where("game_jam_id",$_GET["gameJameId"])->get();
}
else{
$groups = Group::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' => $groups->jsonSerialize()));