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

31 lines
697 B
PHP
Raw Normal View History

2021-03-09 09:45:05 +00:00
<?php
2021-03-16 11:46:44 +00:00
require_once "../../../bootstrap.php";
2021-03-12 13:05:31 +00:00
require_once "Group.php";
2021-03-09 09:45:05 +00:00
use Backend\Models\Group;
2021-04-19 07:15:15 +00:00
if (isLogin()) {
2021-03-09 09:45:05 +00:00
if (isset($_POST['updateGroup'])) {
2021-04-19 07:15:15 +00:00
if ($group = groupViaToken($_SESSION['token'])) {
$group->group_name = $_POST['groupName'];
if (!$group->save()) {
http_response_code(500);
} else {
http_response_code(201);
}
} else {
2021-03-23 12:39:44 +00:00
http_response_code(400);
echo json_encode(["message" => "group not found"]);
}
2021-04-19 07:15:15 +00:00
} else {
2021-03-23 12:39:44 +00:00
http_response_code(400);
2021-03-09 09:45:05 +00:00
}
2021-04-19 07:15:15 +00:00
} else {
2021-03-23 12:39:44 +00:00
http_response_code(401);
echo json_encode(["message" => "is not login"]);
2021-03-12 13:05:31 +00:00
}
2021-03-09 12:16:34 +00:00
2021-03-09 09:45:05 +00:00