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

34 lines
837 B
PHP

<?php
require_once "../../../bootstrap.php";
require_once "Group.php";
use Backend\Models\Group;
if(isLogin()){
if (isset($_POST['updateGroup'])) {
if($group = groupViaToken($_SESSION['token'])){
$group->group_name = $_POST['groupName'];
$group->group_amount = $_POST['groupAmount'];
$group->game_jam_id = $_POST['gameJamId'];
if(!$group->save()){
http_response_code(500);
}else{
http_response_code(201);
}
}
else{
http_response_code(400);
echo json_encode(["message" => "group not found"]);
}
}else{
http_response_code(400);
}
}else{
http_response_code(401);
echo json_encode(["message" => "is not login"]);
}