Game-Jaming/Backend/Controllers/Registration/GetRegistration.php

20 lines
787 B
PHP

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