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

38 lines
1.1 KiB
PHP

<?php
require_once "../../../bootstrap.php";
require_once "../Admin/Admin.php";
use Backend\Models\GameJam;
if(isAdmin()){
if(isset($_POST['updateGameJam'])) {
$gameJam = GameJam::find($_POST['gameJamId']);
if($gameJam){
$gameJam->name = $_POST['gameJamName'];
$gameJam->start_time = $_POST["startDate"]."T".$_POST["startTime"];
$gameJam->end_time = $_POST["endDate"]."T".$_POST["endTime"];
if (!empty($_POST['keyWord'])) {
$gameJam->key_word = $_POST['keyWord'];
}else{
$gameJam->key_word = null;
}
$gameJam->description = $_POST['description'];
if ($gameJam->save()) {
header("location: ../../../Frontend/Html/AdminPage.html?success=UpdatedFile");
exit();
}
}
}else{
header("location: ../../../Frontend/Html/AdminPage.html?error=FailedToUpdatedGameJam");
exit();
}
}else{
header("location: ../../../Frontend/index.html?error=NotAdmin");
exit();
}