voting
This commit is contained in:
parent
d2182f5020
commit
93b9411c99
|
@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
class GameData extends Eloquent
|
class GameData extends Eloquent
|
||||||
{
|
{
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'gameLink', 'isWebBased'
|
'gameLink', 'isWebBased', "img"
|
||||||
];
|
];
|
||||||
|
|
||||||
public function group(){
|
public function group(){
|
||||||
|
|
|
@ -19,4 +19,8 @@ class Group extends Eloquent
|
||||||
public function password(){
|
public function password(){
|
||||||
return $this->hasOne(Password::class);
|
return $this->hasOne(Password::class);
|
||||||
}
|
}
|
||||||
|
public function vote(){
|
||||||
|
return $this->hasMany(Vote::class);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ namespace Backend\Models;
|
||||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
class Password extends Eloquent{
|
class Password extends Eloquent{
|
||||||
protected $fillable =[
|
protected $fillable =[
|
||||||
'password'
|
'password', 'remember_token'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Backend\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
|
|
||||||
|
class Vote extends Eloquent
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'points', 'comment'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
public function group()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Group::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Backend\Models\Group;
|
||||||
|
use Backend\Models\Vote;
|
||||||
|
require "../../bootstrap.php";
|
||||||
|
|
||||||
|
|
||||||
|
if(isset($_POST['1vote_for'])){
|
||||||
|
require "VoteChecking.php";
|
||||||
|
|
||||||
|
$vote = new Vote();
|
||||||
|
$vote->group()->associate(Group::find($_POST['groupId']));
|
||||||
|
$vote->points += 1;
|
||||||
|
if(!empty($_POST['comment'])){
|
||||||
|
$vote->comment = $_POST['comment'];
|
||||||
|
}
|
||||||
|
$vote->save();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Backend\Models\Group;
|
||||||
|
use Backend\Models\Vote;
|
||||||
|
require "../../bootstrap.php";
|
||||||
|
|
||||||
|
|
||||||
|
if(isset($_POST['321vote_for'])){
|
||||||
|
require "VoteChecking.php";
|
||||||
|
|
||||||
|
//give 1 point
|
||||||
|
$vote = new Vote();
|
||||||
|
$vote->group()->associate(Group::find($_POST['1pGroupId']));
|
||||||
|
$vote->points += 1;
|
||||||
|
if(!empty($_POST['1pComment'])){
|
||||||
|
$vote->comment = $_POST['1pComment'];
|
||||||
|
}
|
||||||
|
$vote->save();
|
||||||
|
//give 2 point
|
||||||
|
$vote = new Vote();
|
||||||
|
$vote->group()->associate(Group::find($_POST['2pGroupId']));
|
||||||
|
$vote->points += 2;
|
||||||
|
if(!empty($_POST['2pComment'])){
|
||||||
|
$vote->comment = $_POST['2pComment'];
|
||||||
|
}
|
||||||
|
$vote->save();
|
||||||
|
//give 3 point
|
||||||
|
$vote = new Vote();
|
||||||
|
$vote->group()->associate(Group::find($_POST['3pGroupId']));
|
||||||
|
$vote->points += 3;
|
||||||
|
if(!empty($_POST['3pComment'])){
|
||||||
|
$vote->comment = $_POST['3pComment'];
|
||||||
|
}
|
||||||
|
$vote->save();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
$votes = array();
|
||||||
|
if(isset($_COOKIE["Voting_reg"])) {
|
||||||
|
$votes = unserialize($_COOKIE["Voting_reg"]);
|
||||||
|
foreach ($votes as $vote){
|
||||||
|
if($_POST['gameJamId'] === $vote) return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
array_push($votes,$_POST['gameJamId']);
|
||||||
|
setcookie("Voting_reg", serialize($votes), time() + 86400, "/");
|
Loading…
Reference in New Issue