Game-Jaming/Backend/Controllers/GameJam/GetGameJam.php

35 lines
1.0 KiB
PHP
Raw Permalink Normal View History

2021-03-09 09:45:05 +00:00
<?php
2021-03-19 12:38:13 +00:00
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Max-Age: 1000");
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Origin, Cache-Control, Pragma, Authorization, Accept, Accept-Encoding");
header("Access-Control-Allow-Methods: PUT, POST, GET, OPTIONS, DELETE");
2021-04-19 07:15:15 +00:00
require_once(realpath(dirname(__FILE__) . "/../../../bootstrap.php"));
2021-03-10 10:23:40 +00:00
use Backend\Models\GameJam;
2021-03-11 13:22:19 +00:00
2021-04-19 07:15:15 +00:00
if (isset($_GET['gameJamId'])) {
$dbValue = GameJam::find($_GET['gameJamId']);
2021-05-07 10:30:02 +00:00
}elseif (isset($_GET['hasEnded'])){
$hasEnded = $_GET['hasEnded'];
if($hasEnded == 0 OR $hasEnded == 1){
if ($hasEnded){
$dbValue = GameJam::where("is_finished",1)->get();
}else{
$dbValue = GameJam::where("is_finished",0)->get();
}
}
else{
$dbValue = GameJam::all();
}
}
else {
2021-03-11 13:22:19 +00:00
$dbValue = GameJam::all();
}
2021-03-10 10:23:40 +00:00
header('Content-Type: application/json;charset=UTF-8');
2021-03-22 14:29:18 +00:00
echo json_encode(array('data' => $dbValue->jsonSerialize()));
2021-03-19 08:18:19 +00:00
//var_dump(headers_list());