Game-Jaming/Backend/Controllers/Polls/1vote.php

34 lines
589 B
PHP
Raw Normal View History

2021-03-05 12:00:07 +00:00
<?php
use Backend\Models\Group;
use Backend\Models\Vote;
2021-03-12 13:05:31 +00:00
require_once "../../../bootstrap.php";
require_once "Vote.php";
2021-03-05 12:00:07 +00:00
if(isset($_POST['1Vote'])){
2021-03-12 13:05:31 +00:00
if(VoteCheck($_POST['groupId'])){
$vote = new Vote();
$vote->group()->associate(Group::find($_POST['groupId']));
$vote->points += 1;
if(!empty($_POST['comment'])){
$vote->comment = $_POST['comment'];
2021-03-19 12:25:27 +00:00
}
if(!$vote->save()){
http_response_code(500);
2021-03-17 08:43:09 +00:00
}else{
2021-03-19 12:25:27 +00:00
http_response_code(201);
2021-03-12 13:05:31 +00:00
}
2021-03-05 12:00:07 +00:00
}
2021-03-17 08:43:09 +00:00
}else{
2021-03-19 12:25:27 +00:00
http_response_code(400);
2021-03-05 12:00:07 +00:00
}