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

31 lines
697 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'];
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"]);
}