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

41 lines
971 B
PHP
Raw Normal View History

2021-03-05 12:00:07 +00:00
<?php
use Backend\Models\Group;
use Backend\Models\Vote;
2021-04-19 07:15:15 +00:00
2021-03-16 11:46:44 +00:00
require_once "../../../bootstrap.php";
2021-03-05 12:00:07 +00:00
2021-04-19 07:15:15 +00:00
if (isset($_POST['321Vote'])) {
2021-03-12 13:05:31 +00:00
require "Vote.php";
2021-03-05 12:00:07 +00:00
//give 1 point
$vote = new Vote();
$vote->group()->associate(Group::find($_POST['1pGroupId']));
$vote->points += 1;
2021-04-19 07:15:15 +00:00
if (!empty($_POST['1pComment'])) {
2021-03-05 12:00:07 +00:00
$vote->comment = $_POST['1pComment'];
}
$vote->save();
//give 2 point
$vote = new Vote();
$vote->group()->associate(Group::find($_POST['2pGroupId']));
$vote->points += 2;
2021-04-19 07:15:15 +00:00
if (!empty($_POST['2pComment'])) {
2021-03-05 12:00:07 +00:00
$vote->comment = $_POST['2pComment'];
}
$vote->save();
//give 3 point
$vote = new Vote();
$vote->group()->associate(Group::find($_POST['3pGroupId']));
$vote->points += 3;
2021-04-19 07:15:15 +00:00
if (!empty($_POST['3pComment'])) {
2021-03-05 12:00:07 +00:00
$vote->comment = $_POST['3pComment'];
}
$vote->save();
2021-03-17 08:43:09 +00:00
header("location: ../../../Frontend/index.html?success=SavedVote");
exit();
2021-03-05 12:00:07 +00:00
}