2021-03-09 09:45:05 +00:00
|
|
|
<?php
|
2021-03-11 08:28:30 +00:00
|
|
|
require_once "../../../bootstrap.php";
|
2021-03-12 10:10:14 +00:00
|
|
|
require_once "../Admin/Admin.php";
|
2021-03-09 09:45:05 +00:00
|
|
|
use Backend\Models\GameJam;
|
|
|
|
|
2021-03-11 08:28:30 +00:00
|
|
|
if(isAdmin()){
|
|
|
|
if(isset($_POST['updateGameJam'])) {
|
|
|
|
$gameJam = GameJam::find($_POST['gameJamId']);
|
2021-03-09 09:45:05 +00:00
|
|
|
if($gameJam){
|
|
|
|
|
2021-03-12 10:10:14 +00:00
|
|
|
$gameJam->name = $_POST['gameJamName'];
|
2021-03-09 09:45:05 +00:00
|
|
|
|
2021-03-11 08:28:30 +00:00
|
|
|
$gameJam->start_time = $_POST["startDate"]."T".$_POST["startTime"];
|
2021-03-09 09:45:05 +00:00
|
|
|
|
2021-03-11 08:28:30 +00:00
|
|
|
$gameJam->end_time = $_POST["endDate"]."T".$_POST["endTime"];
|
2021-03-09 09:45:05 +00:00
|
|
|
|
2021-03-12 10:10:14 +00:00
|
|
|
if (!empty($_POST['keyWord'])) {
|
2021-03-11 08:28:30 +00:00
|
|
|
$gameJam->key_word = $_POST['keyWord'];
|
2021-03-12 10:10:14 +00:00
|
|
|
}else{
|
|
|
|
$gameJam->key_word = null;
|
2021-03-09 09:45:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$gameJam->description = $_POST['description'];
|
|
|
|
if ($gameJam->save()) {
|
2021-03-23 12:39:44 +00:00
|
|
|
http_response_code(201);
|
2021-03-19 12:25:27 +00:00
|
|
|
}else{
|
2021-03-23 12:39:44 +00:00
|
|
|
http_response_code(500);
|
2021-03-09 09:45:05 +00:00
|
|
|
}
|
2021-03-23 12:39:44 +00:00
|
|
|
}else{
|
|
|
|
http_response_code(400);
|
|
|
|
echo json_encode(["message" => "game jam not found"]);
|
2021-03-09 09:45:05 +00:00
|
|
|
}
|
2021-03-17 08:43:09 +00:00
|
|
|
}else{
|
2021-03-23 12:39:44 +00:00
|
|
|
http_response_code(400);
|
2021-03-09 09:45:05 +00:00
|
|
|
}
|
2021-03-17 08:43:09 +00:00
|
|
|
}else{
|
2021-03-23 12:39:44 +00:00
|
|
|
http_response_code(401);
|
|
|
|
echo json_encode(["message" => "is not admin"]);
|
2021-03-09 09:45:05 +00:00
|
|
|
}
|