34 lines
589 B
PHP
34 lines
589 B
PHP
<?php
|
|
|
|
use Backend\Models\Group;
|
|
use Backend\Models\Vote;
|
|
require_once "../../../bootstrap.php";
|
|
require_once "Vote.php";
|
|
|
|
|
|
if(isset($_POST['1Vote'])){
|
|
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'];
|
|
}
|
|
if(!$vote->save()){
|
|
http_response_code(500);
|
|
}else{
|
|
http_response_code(201);
|
|
}
|
|
}
|
|
}else{
|
|
http_response_code(400);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|