commit
ae719b9d68
|
@ -7,31 +7,31 @@ use Backend\Models\AdminUser;
|
||||||
//Start the php session
|
//Start the php session
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
if(isset($_POST['aLogin'])){
|
if (isset($_POST['aLogin'])) {
|
||||||
|
|
||||||
$userName = $_POST["userName"];
|
$userName = $_POST["userName"];
|
||||||
$password = $_POST["password"];
|
$password = $_POST["password"];
|
||||||
|
|
||||||
$user = AdminUser::firstWhere('user_name', $userName );
|
$user = AdminUser::firstWhere('user_name', $userName);
|
||||||
if($user){
|
if ($user) {
|
||||||
$hashedPassword = $user->password;
|
$hashedPassword = $user->password;
|
||||||
if(password_verify($password, $hashedPassword )){
|
if (password_verify($password, $hashedPassword)) {
|
||||||
$_SESSION['userName'] = $userName;
|
$_SESSION['userName'] = $userName;
|
||||||
$_SESSION['admin'] = true;
|
$_SESSION['admin'] = true;
|
||||||
$_SESSION['success'] = "You are now logged in";
|
$_SESSION['success'] = "You are now logged in";
|
||||||
http_response_code(200);
|
http_response_code(200);
|
||||||
makeAdminLogin($userName);
|
makeAdminLogin($userName);
|
||||||
}else{
|
} else {
|
||||||
session_destroy();
|
session_destroy();
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(["message" => "wrong password"]);
|
echo json_encode(["message" => "wrong password"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
session_destroy();
|
session_destroy();
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(["message" => "admin don't exist"]);
|
echo json_encode(["message" => "admin don't exist"]);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
}
|
}
|
|
@ -4,20 +4,20 @@ require_once "Admin.php";
|
||||||
|
|
||||||
use Backend\Models\AdminUser;
|
use Backend\Models\AdminUser;
|
||||||
|
|
||||||
if (isAdmin()){
|
if (isAdmin()) {
|
||||||
if (isset($_POST["newAdmin"])){
|
if (isset($_POST["newAdmin"])) {
|
||||||
$admin = new AdminUser();
|
$admin = new AdminUser();
|
||||||
$admin->user_name = $_POST["newUsername"];
|
$admin->user_name = $_POST["newUsername"];
|
||||||
$admin->password = $_POST["newPassword"];
|
$admin->password = $_POST["newPassword"];
|
||||||
if ($admin->save()){
|
if ($admin->save()) {
|
||||||
http_response_code(201);
|
http_response_code(201);
|
||||||
}else{
|
} else {
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(["message" => "is not admin"]);
|
echo json_encode(["message" => "is not admin"]);
|
||||||
}
|
}
|
|
@ -13,15 +13,15 @@ function ZipFileHandler(string $gameFileName, string $gameFileTmp): string
|
||||||
$headerType = mime_content_type($gameFileTmp);
|
$headerType = mime_content_type($gameFileTmp);
|
||||||
$headerTypeMatch = array('application/zip');
|
$headerTypeMatch = array('application/zip');
|
||||||
|
|
||||||
if(in_array($headerType,$headerTypeMatch)){
|
if (in_array($headerType, $headerTypeMatch)) {
|
||||||
$gameFileNewName = uniqid("", true). "." . $fileActualExtGame;
|
$gameFileNewName = uniqid("", true) . "." . $fileActualExtGame;
|
||||||
if(empty($gameFileName)){
|
if (empty($gameFileName)) {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
rename($gameFileTmp,"../../Games/".$gameFileNewName);
|
rename($gameFileTmp, "../../Games/" . $gameFileNewName);
|
||||||
return $gameFileNewName;
|
return $gameFileNewName;
|
||||||
}else{
|
} else {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
echo json_encode(["message" => "Wrong file type gameFile"]);
|
echo json_encode(["message" => "Wrong file type gameFile"]);
|
||||||
exit();
|
exit();
|
||||||
|
@ -39,17 +39,17 @@ function imagesFileHandler(string $thumbnailFileName, string $thumbnailFileTmp):
|
||||||
$fileActualExtThumb = strtolower(end($fileExtThumb));
|
$fileActualExtThumb = strtolower(end($fileExtThumb));
|
||||||
|
|
||||||
$headerType = mime_content_type($thumbnailFileTmp);
|
$headerType = mime_content_type($thumbnailFileTmp);
|
||||||
$headerTypeMatch = array('image/png', 'image/jpeg','image/gif', 'image/svg+xml',);
|
$headerTypeMatch = array('image/png', 'image/jpeg', 'image/gif', 'image/svg+xml',);
|
||||||
|
|
||||||
if(in_array($headerType,$headerTypeMatch)){
|
if (in_array($headerType, $headerTypeMatch)) {
|
||||||
$thumbnailFileNewName = uniqid("", true). "." . $fileActualExtThumb;
|
$thumbnailFileNewName = uniqid("", true) . "." . $fileActualExtThumb;
|
||||||
if(empty($thumbnailFileName)){
|
if (empty($thumbnailFileName)) {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
rename($thumbnailFileTmp,"../../../Frontend/images/".$thumbnailFileNewName);
|
rename($thumbnailFileTmp, "../../../Frontend/images/" . $thumbnailFileNewName);
|
||||||
return $thumbnailFileNewName;
|
return $thumbnailFileNewName;
|
||||||
}else{
|
} else {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
echo json_encode(["message" => "Wrong file type thumbnailFile"]);
|
echo json_encode(["message" => "Wrong file type thumbnailFile"]);
|
||||||
exit();
|
exit();
|
||||||
|
|
|
@ -1,16 +1,21 @@
|
||||||
<?php
|
<?php
|
||||||
require_once "../../../bootstrap.php";
|
require_once "../../../bootstrap.php";
|
||||||
|
|
||||||
use \Backend\Models\GameData;
|
use \Backend\Models\GameData;
|
||||||
use \Backend\Models\Group;
|
use \Backend\Models\Group;
|
||||||
|
use Backend\Models\Registration;
|
||||||
|
|
||||||
if(isset($_GET['gameDataId'])){
|
if (isset($_GET['gameDataId'])) {
|
||||||
$openGameDataStream = GameData::find($_GET['gameDataId']);
|
$openGameDataStream = GameData::find($_GET['gameDataId']);
|
||||||
}elseif(isset($_GET['groupId'])){
|
} elseif (isset($_GET['registrationId'])) {
|
||||||
$openGameDataStream = Group::find($_GET['groupId'])->GameData();
|
$openGameDataStream = Registration::find($_GET['registrationId']);
|
||||||
}elseif (isset($_GET['gameJamId'])){
|
} elseif (isset($_GET['groupId'])) {
|
||||||
$gameDataIds = Group::where("game_jam_id",$_GET['gameJamId'])->pluck("game_data_id")->toArray();
|
$registrationIds = Registration::where("group_id", $_GET['groupId'])->pluck("game_data_id")->toArray();
|
||||||
|
$openGameDataStream = GameData::whereIn("id", $registrationIds)->get();
|
||||||
|
} elseif (isset($_GET['gameJamId'])) {
|
||||||
|
$gameDataIds = Group::where("game_jam_id", $_GET['gameJamId'])->pluck("game_data_id")->toArray();
|
||||||
$openGameDataStream = GameData::whereIn("id", $gameDataIds)->get();
|
$openGameDataStream = GameData::whereIn("id", $gameDataIds)->get();
|
||||||
}else{
|
} else {
|
||||||
$openGameDataStream = GameData::all();
|
$openGameDataStream = GameData::all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,31 @@
|
||||||
require_once "../../../bootstrap.php";
|
require_once "../../../bootstrap.php";
|
||||||
require_once('../Group/Group.php');
|
require_once('../Group/Group.php');
|
||||||
require_once('FileHandler.php');
|
require_once('FileHandler.php');
|
||||||
use Backend\Models\GameData;
|
|
||||||
|
|
||||||
if(isLogin()){
|
use Backend\Models\GameData;
|
||||||
if(isset($_POST['submitUpdate'])){
|
use Backend\Models\Registration;
|
||||||
|
|
||||||
|
if (isLogin()) {
|
||||||
|
if (isset($_POST['submitUpdate'])) {
|
||||||
|
//Get the game data
|
||||||
|
$gameData = GameData::find($_POST['gameDataId']);
|
||||||
|
if ($gameData === null) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(["message" => "game data not found"]);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
//Get the group
|
||||||
|
$group = groupViaToken($_SESSION['token']);
|
||||||
|
if (!in_array($gameData->id, Registration::where("group_id", $group->id)->pluck("game_data_id")->toArray())) {
|
||||||
|
http_response_code(401);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
$gameFile = $_FILES['gameFile'];
|
$gameFile = $_FILES['gameFile'];
|
||||||
$desc = $_POST['description'];
|
$desc = $_POST['description'];
|
||||||
$title = $_POST['gameTitle'];
|
$title = $_POST['gameTitle'];
|
||||||
$thumbnail = $_FILES['thumbnailFile'];
|
$thumbnail = $_FILES['thumbnailFile'];
|
||||||
$isWebBased = isset( $_POST['isWebBased']);
|
$isWebBased = isset($_POST['isWebBased']);
|
||||||
|
|
||||||
$gameFileName = $_FILES['gameFile']['name'];//Game name
|
$gameFileName = $_FILES['gameFile']['name'];//Game name
|
||||||
$gameFileTmp = $_FILES['gameFile']['tmp_name'];//Tmp location of the file
|
$gameFileTmp = $_FILES['gameFile']['tmp_name'];//Tmp location of the file
|
||||||
|
@ -18,34 +34,29 @@ if(isLogin()){
|
||||||
|
|
||||||
$thumbnailFileName = $_FILES['thumbnailFile']['name'];//Game name
|
$thumbnailFileName = $_FILES['thumbnailFile']['name'];//Game name
|
||||||
$thumbnailFileTmp = $_FILES['thumbnailFile']['tmp_name'];//Tmp location of the file
|
$thumbnailFileTmp = $_FILES['thumbnailFile']['tmp_name'];//Tmp location of the file
|
||||||
$thumbnailFileError =$_FILES['thumbnailFile']['error'];//File error
|
$thumbnailFileError = $_FILES['thumbnailFile']['error'];//File error
|
||||||
|
|
||||||
|
|
||||||
//Get the group
|
|
||||||
$group = groupViaToken($_SESSION['token']);
|
|
||||||
//Get the game data, from the group
|
|
||||||
$gameData = GameData::find($group->game_data_id);
|
|
||||||
$gameData->game_name = $title;
|
$gameData->game_name = $title;
|
||||||
if(isset($gameData) && $gameFileError === 0){
|
if (isset($gameData) && $gameFileError === 0) {
|
||||||
unlink("../../Games/".$gameData->game_link);
|
unlink("../../Games/" . $gameData->game_link);
|
||||||
$gameData->game_link = ZipFileHandler($gameFileName,$gameFileTmp);
|
$gameData->game_link = ZipFileHandler($gameFileName, $gameFileTmp);
|
||||||
}
|
}
|
||||||
$gameData->description = $desc;
|
$gameData->description = $desc;
|
||||||
if(isset($thumbnail) && $thumbnailFileError === 0){
|
if (isset($thumbnail) && $thumbnailFileError === 0) {
|
||||||
unlink("../../../Frontend/images/".$gameData->img);
|
unlink("../../../Frontend/images/" . $gameData->img);
|
||||||
$gameData->img = imagesFileHandler($thumbnailFileName,$thumbnailFileTmp);
|
$gameData->img = imagesFileHandler($thumbnailFileName, $thumbnailFileTmp);
|
||||||
}
|
}
|
||||||
$gameData->is_web_Based = $isWebBased;
|
$gameData->is_web_Based = $isWebBased;
|
||||||
if(!$gameData->save()){
|
if (!$gameData->save()) {
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
}else{
|
} else {
|
||||||
http_response_code(201);
|
http_response_code(201);
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(["message" => "is not login"]);
|
echo json_encode(["message" => "is not login"]);
|
||||||
}
|
}
|
|
@ -2,8 +2,10 @@
|
||||||
require_once "../../../bootstrap.php";
|
require_once "../../../bootstrap.php";
|
||||||
require_once('../Group/Group.php');
|
require_once('../Group/Group.php');
|
||||||
require_once('FileHandler.php');
|
require_once('FileHandler.php');
|
||||||
|
|
||||||
use Backend\Models\GameData;
|
use Backend\Models\GameData;
|
||||||
use Backend\Models\GameJam;
|
use Backend\Models\GameJam;
|
||||||
|
use Backend\Models\Registration;
|
||||||
|
|
||||||
use Backend\Models\Group;
|
use Backend\Models\Group;
|
||||||
|
|
||||||
|
@ -12,26 +14,37 @@ date_default_timezone_set("Europe/Copenhagen");
|
||||||
$isImages = false;
|
$isImages = false;
|
||||||
|
|
||||||
|
|
||||||
if(isLogin()){
|
if (isLogin()) {
|
||||||
|
if (isset($_POST['submitUpload'])) {
|
||||||
$group = groupViaToken($_SESSION['token']);
|
$group = groupViaToken($_SESSION['token']);
|
||||||
|
$gameJam = GameJam::find($_POST['gameJamId']);
|
||||||
|
if ($gameJam === null) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(["message" => "gameJam not found"]);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
$registration = Registration::where('game_jam_id', $gameJam->id)->where("group_id", $group->id)->frist();
|
||||||
|
if ($registration === null) {
|
||||||
|
http_response_code(401);
|
||||||
|
echo json_encode(["message" => "group not registered for that game jam"]);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$gameJam = GameJam::find($group->game_jam_id);
|
|
||||||
$gameJamStartTime = strtotime($gameJam->start_time);
|
$gameJamStartTime = strtotime($gameJam->start_time);
|
||||||
$gameJamEndTime = strtotime($gameJam->end_time);
|
$gameJamEndTime = strtotime($gameJam->end_time);
|
||||||
$date = date('Y/m/d H:i:s', time());
|
$date = date('Y/m/d H:i:s', time());
|
||||||
|
|
||||||
$currentTime = strtotime($date);
|
$currentTime = strtotime($date);
|
||||||
|
|
||||||
if($gameJamStartTime <= $currentTime && $gameJamEndTime >= $currentTime){
|
if ($gameJamStartTime <= $currentTime && $gameJamEndTime >= $currentTime) {
|
||||||
if(!isset($group->game_data_id)){
|
if (!isset($registration->game_data_id)) {
|
||||||
if(isset($_POST['submitUpload'])){
|
|
||||||
//Get the data from the user form
|
//Get the data from the user form
|
||||||
$gameFile = $_FILES['gameFile'];
|
$gameFile = $_FILES['gameFile'];
|
||||||
$desc = $_POST['description'];
|
$desc = $_POST['description'];
|
||||||
$title = $_POST['gameTitle'];
|
$title = $_POST['gameTitle'];
|
||||||
$thumbnail = $_FILES['thumbnailFile'];
|
$thumbnail = $_FILES['thumbnailFile'];
|
||||||
$isWebBased = isset( $_POST['isWebBased']);
|
$isWebBased = isset($_POST['isWebBased']);
|
||||||
|
|
||||||
$gameFileName = $_FILES['gameFile']['name'];//Game name
|
$gameFileName = $_FILES['gameFile']['name'];//Game name
|
||||||
$gameFileTmp = $_FILES['gameFile']['tmp_name'];//Tmp location of the file
|
$gameFileTmp = $_FILES['gameFile']['tmp_name'];//Tmp location of the file
|
||||||
|
@ -39,40 +52,40 @@ if(isLogin()){
|
||||||
|
|
||||||
$thumbnailFileName = $_FILES['thumbnailFile']['name'];//Game name
|
$thumbnailFileName = $_FILES['thumbnailFile']['name'];//Game name
|
||||||
$thumbnailFileTmp = $_FILES['thumbnailFile']['tmp_name'];//Tmp location of the file
|
$thumbnailFileTmp = $_FILES['thumbnailFile']['tmp_name'];//Tmp location of the file
|
||||||
$thumbnailFileError =$_FILES['thumbnailFile']['error'];//File error
|
$thumbnailFileError = $_FILES['thumbnailFile']['error'];//File error
|
||||||
|
|
||||||
if($gameFileError === 0){
|
if ($gameFileError === 0) {
|
||||||
$gameData = new GameData();
|
$gameData = new GameData();
|
||||||
$gameData->game_name = $title;
|
$gameData->game_name = $title;
|
||||||
$gameData->game_link = ZipFileHandler($gameFileName,$gameFileTmp);
|
$gameData->game_link = ZipFileHandler($gameFileName, $gameFileTmp);
|
||||||
$gameData->description = $desc;
|
$gameData->description = $desc;
|
||||||
if(isset($thumbnail) && $thumbnailFileError === 0){
|
if (isset($thumbnail) && $thumbnailFileError === 0) {
|
||||||
$gameData->img = imagesFileHandler($thumbnailFileName,$thumbnailFileTmp);
|
$gameData->img = imagesFileHandler($thumbnailFileName, $thumbnailFileTmp);
|
||||||
}
|
}
|
||||||
$gameData->is_web_Based = $isWebBased;
|
$gameData->is_web_Based = $isWebBased;
|
||||||
$gameData->save();
|
$gameData->save();
|
||||||
$group->gameData()->associate($gameData);
|
$registration->gameData()->associate($gameData);
|
||||||
if(! $group->save()){
|
if (!$registration->save()) {
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
}else{
|
} else {
|
||||||
http_response_code(201);
|
http_response_code(201);
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
|
echo json_encode(["message" => "file already uploaded "]);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
http_response_code(400);
|
|
||||||
echo json_encode(["message" => "Can only upload one file"]);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
echo json_encode(["message" => "Can only upload when the game jam has started"]);
|
echo json_encode(["message" => "Can only upload when the game jam has started"]);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
|
http_response_code(400);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(["message" => "is not login"]);
|
echo json_encode(["message" => "is not login"]);
|
||||||
}
|
}
|
|
@ -4,13 +4,14 @@ header("Access-Control-Allow-Credentials: true");
|
||||||
header("Access-Control-Max-Age: 1000");
|
header("Access-Control-Max-Age: 1000");
|
||||||
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Origin, Cache-Control, Pragma, Authorization, Accept, Accept-Encoding");
|
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Origin, Cache-Control, Pragma, Authorization, Accept, Accept-Encoding");
|
||||||
header("Access-Control-Allow-Methods: PUT, POST, GET, OPTIONS, DELETE");
|
header("Access-Control-Allow-Methods: PUT, POST, GET, OPTIONS, DELETE");
|
||||||
require_once (realpath(dirname(__FILE__) ."/../../../bootstrap.php"));
|
require_once(realpath(dirname(__FILE__) . "/../../../bootstrap.php"));
|
||||||
|
|
||||||
use Backend\Models\GameJam;
|
use Backend\Models\GameJam;
|
||||||
|
|
||||||
|
|
||||||
if(isset($_GET['gameJamId'])){
|
if (isset($_GET['gameJamId'])) {
|
||||||
$dbValue = GameJam::find($_GET['gameJamId']);
|
$dbValue = GameJam::find($_GET['gameJamId']);
|
||||||
}else{
|
} else {
|
||||||
$dbValue = GameJam::all();
|
$dbValue = GameJam::all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,34 +1,34 @@
|
||||||
<?php
|
<?php
|
||||||
require_once "../../../bootstrap.php";
|
require_once "../../../bootstrap.php";
|
||||||
require_once "../Admin/Admin.php";
|
require_once "../Admin/Admin.php";
|
||||||
|
|
||||||
use Backend\Models\GameJam;
|
use Backend\Models\GameJam;
|
||||||
|
|
||||||
//var_dump($_POST);
|
//var_dump($_POST);
|
||||||
|
|
||||||
//session_start();
|
//session_start();
|
||||||
|
|
||||||
if(isAdmin()){
|
if (isAdmin()) {
|
||||||
if(isset($_POST['newGameJam'])){
|
if (isset($_POST['newGameJam'])) {
|
||||||
$gameJam = New GameJam();
|
$gameJam = new GameJam();
|
||||||
|
|
||||||
$gameJam->name = $_POST["gameJamName"];
|
$gameJam->name = $_POST["gameJamName"];
|
||||||
$gameJam->start_time = $_POST["startDate"]."T".$_POST["startTime"];
|
$gameJam->start_time = $_POST["startDate"] . "T" . $_POST["startTime"];
|
||||||
$gameJam->end_time = $_POST["endDate"]."T".$_POST["endTime"];
|
$gameJam->end_time = $_POST["endDate"] . "T" . $_POST["endTime"];
|
||||||
if (!empty($_POST['keyWord'])) {
|
if (!empty($_POST['keyWord'])) {
|
||||||
$gameJam->key_word = $_POST['keyWord'];
|
$gameJam->key_word = $_POST['keyWord'];
|
||||||
}
|
}
|
||||||
$gameJam->description = $_POST["description"];
|
$gameJam->description = $_POST["description"];
|
||||||
|
|
||||||
if($gameJam->save()){
|
if ($gameJam->save()) {
|
||||||
http_response_code(201);
|
http_response_code(201);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(["message" => "is not admin"]);
|
echo json_encode(["message" => "is not admin"]);
|
||||||
}
|
}
|
|
@ -1,39 +1,40 @@
|
||||||
<?php
|
<?php
|
||||||
require_once "../../../bootstrap.php";
|
require_once "../../../bootstrap.php";
|
||||||
require_once "../Admin/Admin.php";
|
require_once "../Admin/Admin.php";
|
||||||
|
|
||||||
use Backend\Models\GameJam;
|
use Backend\Models\GameJam;
|
||||||
|
|
||||||
if(isAdmin()){
|
if (isAdmin()) {
|
||||||
if(isset($_POST['updateGameJam'])) {
|
if (isset($_POST['updateGameJam'])) {
|
||||||
$gameJam = GameJam::find($_POST['gameJamId']);
|
$gameJam = GameJam::find($_POST['gameJamId']);
|
||||||
if($gameJam){
|
if ($gameJam) {
|
||||||
|
|
||||||
$gameJam->name = $_POST['gameJamName'];
|
$gameJam->name = $_POST['gameJamName'];
|
||||||
|
|
||||||
$gameJam->start_time = $_POST["startDate"]."T".$_POST["startTime"];
|
$gameJam->start_time = $_POST["startDate"] . "T" . $_POST["startTime"];
|
||||||
|
|
||||||
$gameJam->end_time = $_POST["endDate"]."T".$_POST["endTime"];
|
$gameJam->end_time = $_POST["endDate"] . "T" . $_POST["endTime"];
|
||||||
|
|
||||||
if (!empty($_POST['keyWord'])) {
|
if (!empty($_POST['keyWord'])) {
|
||||||
$gameJam->key_word = $_POST['keyWord'];
|
$gameJam->key_word = $_POST['keyWord'];
|
||||||
}else{
|
} else {
|
||||||
$gameJam->key_word = null;
|
$gameJam->key_word = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$gameJam->description = $_POST['description'];
|
$gameJam->description = $_POST['description'];
|
||||||
if ($gameJam->save()) {
|
if ($gameJam->save()) {
|
||||||
http_response_code(201);
|
http_response_code(201);
|
||||||
}else{
|
} else {
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
echo json_encode(["message" => "game jam not found"]);
|
echo json_encode(["message" => "game jam not found"]);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(["message" => "is not admin"]);
|
echo json_encode(["message" => "is not admin"]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
require_once "../../../bootstrap.php";
|
require_once "../../../bootstrap.php";
|
||||||
|
|
||||||
use Backend\Models\Group;
|
use Backend\Models\Group;
|
||||||
|
|
||||||
if (isset($_GET["groupId"])){
|
if (isset($_GET["groupId"])) {
|
||||||
$groups = Group::find($_GET["groupId"]);
|
$groups = Group::find($_GET["groupId"]);
|
||||||
}
|
} elseif (isset($_GET["gameJameId"])) {
|
||||||
elseif(isset($_GET["gameJameId"])){
|
$registrationIds = Registration::where("game_jam_id", $_GET["gameJameId"])->pluck("game_data_id")->toArray();
|
||||||
$groups = Group::where("game_jam_id",$_GET["gameJameId"])->get();
|
$groups = Group::whereIn("id", $registrationIds)->get();
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$groups = Group::all();
|
$groups = Group::all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
require_once (realpath(dirname(__FILE__) ."/../../../bootstrap.php"));
|
require_once(realpath(dirname(__FILE__) . "/../../../bootstrap.php"));
|
||||||
|
|
||||||
use Backend\Models\Group;
|
use Backend\Models\Group;
|
||||||
use Backend\Models\Password;
|
use Backend\Models\Password;
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,7 +15,7 @@ session_start();
|
||||||
function groupViaToken(string $token): ?Group
|
function groupViaToken(string $token): ?Group
|
||||||
{
|
{
|
||||||
|
|
||||||
if($password = Password::firstWhere('remember_token', $token)){
|
if ($password = Password::firstWhere('remember_token', $token)) {
|
||||||
return Group::find($password->group_id);
|
return Group::find($password->group_id);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -39,10 +40,9 @@ function passwordValidate(string $password1): bool
|
||||||
$number = preg_match('@[0-9]@', $password1);
|
$number = preg_match('@[0-9]@', $password1);
|
||||||
$specialChars = preg_match('@[^\w]@', $password1);
|
$specialChars = preg_match('@[^\w]@', $password1);
|
||||||
|
|
||||||
if(!$uppercase || !$lowercase || !$number || !$specialChars || (strlen($password1) >= 8 && strlen($password1) <= 255) ) {
|
if (!$uppercase || !$lowercase || !$number || !$specialChars || (strlen($password1) >= 8 && strlen($password1) <= 255)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
} else return false;
|
||||||
else return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeLogin(string $groupName, int $groupId)
|
function makeLogin(string $groupName, int $groupId)
|
||||||
|
|
|
@ -9,44 +9,43 @@ use Illuminate\Support\Str;
|
||||||
|
|
||||||
//Start the php session
|
//Start the php session
|
||||||
|
|
||||||
if(isset($_POST['login'])){
|
if (isset($_POST['login'])) {
|
||||||
|
|
||||||
$groupName = $_POST["groupName"];
|
$groupName = $_POST["groupName"];
|
||||||
$password = $_POST["password"];
|
$password = $_POST["password"];
|
||||||
|
|
||||||
$group = Group::firstWhere('group_name', $groupName );
|
$group = Group::firstWhere('group_name', $groupName);
|
||||||
if($group){
|
if ($group) {
|
||||||
$hashedPassword = $group->password->password;
|
$hashedPassword = $group->password->password;
|
||||||
if(password_verify($password, $hashedPassword )){
|
if (password_verify($password, $hashedPassword)) {
|
||||||
$token = Str::random(100);
|
$token = Str::random(100);
|
||||||
$groupPassword = Password::firstWhere('group_id', $group->id);
|
$groupPassword = Password::firstWhere('group_id', $group->id);
|
||||||
$groupPassword->remember_token = $token;
|
$groupPassword->remember_token = $token;
|
||||||
if($groupPassword->save()){
|
if ($groupPassword->save()) {
|
||||||
$_SESSION['token'] = $token;
|
$_SESSION['token'] = $token;
|
||||||
$_SESSION['success'] = "You are now logged in";
|
$_SESSION['success'] = "You are now logged in";
|
||||||
makeLogin($groupName,$group->id);
|
makeLogin($groupName, $group->id);
|
||||||
//header('location: ../../../Frontend/index.php?login=success');
|
//header('location: ../../../Frontend/index.php?login=success');
|
||||||
//exit();
|
//exit();
|
||||||
http_response_code(200);
|
http_response_code(200);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
session_destroy();
|
session_destroy();
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
session_destroy();
|
session_destroy();
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(["message" => "Wrong password"]);
|
echo json_encode(["message" => "Wrong password"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
session_destroy();
|
session_destroy();
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(["message" => "group was not found"]);
|
echo json_encode(["message" => "group was not found"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,26 +5,26 @@ require_once "../Admin/Admin.php";
|
||||||
use \Backend\Models\Password;
|
use \Backend\Models\Password;
|
||||||
|
|
||||||
//session_start();
|
//session_start();
|
||||||
if(isAdmin()){
|
if (isAdmin()) {
|
||||||
if(isset($_POST['restPassword'])){
|
if (isset($_POST['restPassword'])) {
|
||||||
$password = Password::firstWhere("group_id",$_POST['groupId']);
|
$password = Password::firstWhere("group_id", $_POST['groupId']);
|
||||||
if($password){
|
if ($password) {
|
||||||
$password->password = password_hash($_POST['newPassword'], PASSWORD_DEFAULT);
|
$password->password = password_hash($_POST['newPassword'], PASSWORD_DEFAULT);
|
||||||
echo $password;
|
echo $password;
|
||||||
if(!$password->save()){
|
if (!$password->save()) {
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
}else{
|
} else {
|
||||||
http_response_code(201);
|
http_response_code(201);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
echo json_encode(["message" => "group not found"]);
|
echo json_encode(["message" => "group not found"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(["message" => "is not admin"]);
|
echo json_encode(["message" => "is not admin"]);
|
||||||
}
|
}
|
|
@ -11,34 +11,31 @@ use Illuminate\Support\Str;
|
||||||
$groupName = "";
|
$groupName = "";
|
||||||
$errors = array();
|
$errors = array();
|
||||||
|
|
||||||
if(isset($_POST['regGroup'])){
|
if (isset($_POST['regGroup'])) {
|
||||||
|
|
||||||
|
|
||||||
if(passwordValidate($pass = $_POST['password'])){
|
if (passwordValidate($pass = $_POST['password'])) {
|
||||||
$group = new Group();
|
$group = new Group();
|
||||||
|
|
||||||
$group->gameJam()->associate(GameJam::find($_POST['gameJamId']));
|
|
||||||
|
|
||||||
$group->group_name = $groupName = $_POST['groupName'];
|
$group->group_name = $groupName = $_POST['groupName'];
|
||||||
|
|
||||||
$group->group_amount = $_POST['groupAmount'];
|
if (!$group->save()) {
|
||||||
|
|
||||||
if(!$group->save()){
|
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$password = New Password();
|
$password = new Password();
|
||||||
|
|
||||||
$password->group()->associate($group);
|
$password->group()->associate($group);
|
||||||
|
|
||||||
$password->password = password_hash($pass ,PASSWORD_DEFAULT);
|
$password->password = password_hash($pass, PASSWORD_DEFAULT);
|
||||||
|
|
||||||
$token = Str::random(100);
|
$token = Str::random(100);
|
||||||
|
|
||||||
$password->remember_token = $token;
|
$password->remember_token = $token;
|
||||||
|
|
||||||
if(!$password->save()){
|
if (!$password->save()) {
|
||||||
|
$group->delete();
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
@ -46,14 +43,14 @@ if(isset($_POST['regGroup'])){
|
||||||
$_SESSION['groupName'] = $groupName;
|
$_SESSION['groupName'] = $groupName;
|
||||||
$_SESSION['token'] = $token;
|
$_SESSION['token'] = $token;
|
||||||
$_SESSION['success'] = "You are now logged in";
|
$_SESSION['success'] = "You are now logged in";
|
||||||
makeLogin($groupName,$group->id);
|
makeLogin($groupName, $group->id);
|
||||||
http_response_code(201);
|
http_response_code(201);
|
||||||
echo json_encode(["message" => "you are login"]);
|
echo json_encode(["message" => "you are login"]);
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
echo json_encode(["message" => "password not valid"]);
|
echo json_encode(["message" => "password not valid"]);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,26 +4,23 @@ require_once "Group.php";
|
||||||
|
|
||||||
use Backend\Models\Group;
|
use Backend\Models\Group;
|
||||||
|
|
||||||
if(isLogin()){
|
if (isLogin()) {
|
||||||
if (isset($_POST['updateGroup'])) {
|
if (isset($_POST['updateGroup'])) {
|
||||||
if($group = groupViaToken($_SESSION['token'])){
|
if ($group = groupViaToken($_SESSION['token'])) {
|
||||||
$group->group_name = $_POST['groupName'];
|
$group->group_name = $_POST['groupName'];
|
||||||
$group->group_amount = $_POST['groupAmount'];
|
if (!$group->save()) {
|
||||||
$group->game_jam_id = $_POST['gameJamId'];
|
|
||||||
if(!$group->save()){
|
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
}else{
|
} else {
|
||||||
http_response_code(201);
|
http_response_code(201);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
echo json_encode(["message" => "group not found"]);
|
echo json_encode(["message" => "group not found"]);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(["message" => "is not login"]);
|
echo json_encode(["message" => "is not login"]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
<?php
|
<?php
|
||||||
require_once "../../../bootstrap.php";
|
require_once "../../../bootstrap.php";
|
||||||
require_once "Group.php";
|
require_once "Group.php";
|
||||||
|
|
||||||
use Backend\Models\Password;
|
use Backend\Models\Password;
|
||||||
|
|
||||||
if(isLogin()){
|
if (isLogin()) {
|
||||||
if(isset($_POST['updatePassword'])){
|
if (isset($_POST['updatePassword'])) {
|
||||||
$password = Password::firstWhere("group_id", groupViaToken($_SESSION["token"])->id);
|
$password = Password::firstWhere("group_id", groupViaToken($_SESSION["token"])->id);
|
||||||
if(passwordValidate($pass = $_POST['password'])){
|
if (passwordValidate($pass = $_POST['password'])) {
|
||||||
$password->password = password_hash($pass,PASSWORD_DEFAULT);
|
$password->password = password_hash($pass, PASSWORD_DEFAULT);
|
||||||
if(!$password->save()){
|
if (!$password->save()) {
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
}else{
|
} else {
|
||||||
http_response_code(201);
|
http_response_code(201);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
echo json_encode(["message" => "password not valid"]);
|
echo json_encode(["message" => "password not valid"]);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(["message" => "is not login"]);
|
echo json_encode(["message" => "is not login"]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,31 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Backend\Models\Group;
|
use Backend\Models\GameData;
|
||||||
use Backend\Models\Vote;
|
use Backend\Models\Vote;
|
||||||
|
|
||||||
require_once "../../../bootstrap.php";
|
require_once "../../../bootstrap.php";
|
||||||
require_once "Vote.php";
|
require_once "Vote.php";
|
||||||
|
|
||||||
|
|
||||||
if(isset($_POST['1Vote'])){
|
if (isset($_POST['1Vote'])) {
|
||||||
if(VoteCheck($_POST['groupId'])){
|
if (VoteCheck($_POST['gameDataId'])) {
|
||||||
$vote = new Vote();
|
$vote = new Vote();
|
||||||
$vote->group()->associate(Group::find($_POST['groupId']));
|
$vote->gameDate()->associate(GameData::find($_POST['gameDataId']));
|
||||||
|
|
||||||
$vote->points += 1;
|
$vote->points += 1;
|
||||||
if(!empty($_POST['comment'])){
|
if (!empty($_POST['comment'])) {
|
||||||
$vote->comment = $_POST['comment'];
|
$vote->comment = $_POST['comment'];
|
||||||
}
|
}
|
||||||
if(!$vote->save()){
|
if (!$vote->save()) {
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
}else{
|
} else {
|
||||||
http_response_code(201);
|
http_response_code(201);
|
||||||
}
|
}
|
||||||
} else{
|
} else {
|
||||||
http_response_code(403);
|
http_response_code(403);
|
||||||
echo json_encode(["message" => "you have already voted"]);
|
echo json_encode(["message" => "you have already voted"]);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
echo json_encode(["message" => "you have already voted"]);
|
echo json_encode(["message" => "you have already voted"]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,18 @@
|
||||||
|
|
||||||
use Backend\Models\Group;
|
use Backend\Models\Group;
|
||||||
use Backend\Models\Vote;
|
use Backend\Models\Vote;
|
||||||
|
|
||||||
require_once "../../../bootstrap.php";
|
require_once "../../../bootstrap.php";
|
||||||
|
|
||||||
|
|
||||||
if(isset($_POST['321Vote'])){
|
if (isset($_POST['321Vote'])) {
|
||||||
require "Vote.php";
|
require "Vote.php";
|
||||||
|
|
||||||
//give 1 point
|
//give 1 point
|
||||||
$vote = new Vote();
|
$vote = new Vote();
|
||||||
$vote->group()->associate(Group::find($_POST['1pGroupId']));
|
$vote->group()->associate(Group::find($_POST['1pGroupId']));
|
||||||
$vote->points += 1;
|
$vote->points += 1;
|
||||||
if(!empty($_POST['1pComment'])){
|
if (!empty($_POST['1pComment'])) {
|
||||||
$vote->comment = $_POST['1pComment'];
|
$vote->comment = $_POST['1pComment'];
|
||||||
}
|
}
|
||||||
$vote->save();
|
$vote->save();
|
||||||
|
@ -20,7 +21,7 @@ if(isset($_POST['321Vote'])){
|
||||||
$vote = new Vote();
|
$vote = new Vote();
|
||||||
$vote->group()->associate(Group::find($_POST['2pGroupId']));
|
$vote->group()->associate(Group::find($_POST['2pGroupId']));
|
||||||
$vote->points += 2;
|
$vote->points += 2;
|
||||||
if(!empty($_POST['2pComment'])){
|
if (!empty($_POST['2pComment'])) {
|
||||||
$vote->comment = $_POST['2pComment'];
|
$vote->comment = $_POST['2pComment'];
|
||||||
}
|
}
|
||||||
$vote->save();
|
$vote->save();
|
||||||
|
@ -28,7 +29,7 @@ if(isset($_POST['321Vote'])){
|
||||||
$vote = new Vote();
|
$vote = new Vote();
|
||||||
$vote->group()->associate(Group::find($_POST['3pGroupId']));
|
$vote->group()->associate(Group::find($_POST['3pGroupId']));
|
||||||
$vote->points += 3;
|
$vote->points += 3;
|
||||||
if(!empty($_POST['3pComment'])){
|
if (!empty($_POST['3pComment'])) {
|
||||||
$vote->comment = $_POST['3pComment'];
|
$vote->comment = $_POST['3pComment'];
|
||||||
}
|
}
|
||||||
$vote->save();
|
$vote->save();
|
||||||
|
@ -36,5 +37,4 @@ if(isset($_POST['321Vote'])){
|
||||||
exit();
|
exit();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Backend\Models\Vote;
|
use Backend\Models\Vote;
|
||||||
|
|
||||||
require_once "../../../bootstrap.php";
|
require_once "../../../bootstrap.php";
|
||||||
require_once "../Group/Group.php";
|
require_once "../Group/Group.php";
|
||||||
|
|
||||||
if(isLogin()){
|
if (isLogin()) {
|
||||||
header('Content-Type: application/json;charset=UTF-8');
|
header('Content-Type: application/json;charset=UTF-8');
|
||||||
echo json_encode(array('data' => Vote::where('group_id',groupViaToken($_SESSION['token'])->id)->get()->jsonSerialize()));
|
echo json_encode(array('data' => Vote::where('group_id', groupViaToken($_SESSION['token'])->id)->get()->jsonSerialize()));
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(["message" => "not login"]);
|
echo json_encode(["message" => "not login"]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
require_once "../../../bootstrap.php";
|
require_once "../../../bootstrap.php";
|
||||||
require_once "../Admin/Admin.php";
|
require_once "../Admin/Admin.php";
|
||||||
|
|
||||||
use Backend\Models\Group;
|
use Backend\Models\Group;
|
||||||
use Backend\Models\Vote;
|
use Backend\Models\Vote;
|
||||||
use \Illuminate\Support\Collection;
|
use \Illuminate\Support\Collection;
|
||||||
|
|
||||||
if(isAdmin()){
|
if (isAdmin()) {
|
||||||
if(isset($_GET['gameJamId'])) {
|
if (isset($_GET['gameJamId'])) {
|
||||||
$groups = Group::where('game_jam_id', $_GET['gameJamId'])->get();
|
$groups = Group::where('game_jam_id', $_GET['gameJamId'])->get();
|
||||||
if($groups) {
|
if ($groups) {
|
||||||
$winningGroups = new Collection();
|
$winningGroups = new Collection();
|
||||||
$i = -1;
|
$i = -1;
|
||||||
foreach ($groups as $group) {
|
foreach ($groups as $group) {
|
||||||
|
@ -27,16 +28,15 @@ if(isAdmin()){
|
||||||
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept");
|
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept");
|
||||||
header('Content-Type: application/json;charset=UTF-8');
|
header('Content-Type: application/json;charset=UTF-8');
|
||||||
echo json_encode(array('data' => $winningGroups->jsonSerialize()));
|
echo json_encode(array('data' => $winningGroups->jsonSerialize()));
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
echo json_encode(["message" => "game jam not found"]);
|
echo json_encode(["message" => "game jam not found"]);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(["message" => "not admin"]);
|
echo json_encode(["message" => "not admin"]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
require_once "../../../bootstrap.php";
|
require_once "../../../bootstrap.php";
|
||||||
|
|
||||||
use \Backend\Models\Group;
|
use \Backend\Models\Group;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,18 +10,18 @@ use \Backend\Models\Group;
|
||||||
function VoteCheck(string $voteId): bool
|
function VoteCheck(string $voteId): bool
|
||||||
{
|
{
|
||||||
$votes = array();
|
$votes = array();
|
||||||
if(isset($_COOKIE["VotingReg"])) {
|
if (isset($_COOKIE["VotingReg"])) {
|
||||||
|
|
||||||
$votes = unserialize($_COOKIE["VotingReg"]);
|
$votes = unserialize($_COOKIE["VotingReg"]);
|
||||||
foreach ($votes as $vote){
|
foreach ($votes as $vote) {
|
||||||
|
|
||||||
if($voteId === $vote) {
|
if ($voteId === $vote) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
array_push($votes,$voteId);
|
array_push($votes, $voteId);
|
||||||
setcookie("VotingReg", serialize($votes), time() + 86400, "/");
|
setcookie("VotingReg", serialize($votes), time() + 86400, "/");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
<?php
|
|
@ -0,0 +1 @@
|
||||||
|
<?php
|
|
@ -0,0 +1 @@
|
||||||
|
<?php
|
|
@ -2,21 +2,20 @@
|
||||||
require_once "../../../bootstrap.php";
|
require_once "../../../bootstrap.php";
|
||||||
require_once "../Admin/Admin.php";
|
require_once "../Admin/Admin.php";
|
||||||
|
|
||||||
use Backend\Models\Group;
|
|
||||||
use \Backend\Models\KeyWord;
|
use \Backend\Models\KeyWord;
|
||||||
use \Backend\Models\GameJam;
|
use \Backend\Models\GameJam;
|
||||||
use \Illuminate\Support\Collection;
|
use Backend\Models\Registration;
|
||||||
|
|
||||||
if (!isAdmin()){
|
if (!isAdmin()) {
|
||||||
if(isset($_GET['genKeyWord'])){
|
if (isset($_GET['genKeyWord'])) {
|
||||||
$gameJamId = $_GET['gameJamId'];
|
$gameJamId = $_GET['gameJamId'];
|
||||||
$game_jam = GameJam::find($gameJamId);
|
$game_jam = GameJam::find($gameJamId);
|
||||||
$all_group_in_game_jam_id = Group::where("game_jam_id", $game_jam->id)->pluck("id")->toArray();
|
$all_registration_in_game_jam_id = Registration::where("game_jam_id", $game_jam->id)->pluck("id")->toArray();
|
||||||
$find_all_keywords = KeyWord::whereIn("group_id", $all_group_in_game_jam_id)->inRandomOrder()->take(6)->get();
|
$find_all_keywords = KeyWord::whereIn("group_id", $all_registration_in_game_jam_id)->inRandomOrder()->take(6)->get();
|
||||||
$game_jam->key_word = $find_all_keywords->first()->key_word;
|
$game_jam->key_word = $find_all_keywords->first()->key_word;
|
||||||
if(!$game_jam->save()){
|
if (!$game_jam->save()) {
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
}else{
|
} else {
|
||||||
http_response_code(201);
|
http_response_code(201);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,10 +23,10 @@ if (!isAdmin()){
|
||||||
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept");
|
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept");
|
||||||
header('Content-Type: application/json;charset=UTF-8');
|
header('Content-Type: application/json;charset=UTF-8');
|
||||||
echo json_encode(array('data' => $find_all_keywords->jsonSerialize()));
|
echo json_encode(array('data' => $find_all_keywords->jsonSerialize()));
|
||||||
}else{
|
} else {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(["message" => "is not admin"]);
|
echo json_encode(["message" => "is not admin"]);
|
||||||
}
|
}
|
|
@ -1,18 +1,33 @@
|
||||||
<?php
|
<?php
|
||||||
require_once "../../../bootstrap.php";
|
require_once "../../../bootstrap.php";
|
||||||
require_once "../Group/Group.php";
|
require_once "../Group/Group.php";
|
||||||
|
|
||||||
|
use Backend\Models\GameJam;
|
||||||
|
use Backend\Models\Registration;
|
||||||
use Backend\Models\Group;
|
use Backend\Models\Group;
|
||||||
use Backend\Models\KeyWord;
|
use Backend\Models\KeyWord;
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
if (isLogin()) {
|
if (isLogin()) {
|
||||||
if(isset($_POST['submitKeyWord'])){
|
if (isset($_POST['submitKeyWord'])) {
|
||||||
//Find the group id
|
//Find the group
|
||||||
$group = groupViaToken($_SESSION['token']);
|
$group = groupViaToken($_SESSION['token']);
|
||||||
|
|
||||||
|
if($gameJam = GameJam::find($_POST["gameJamId"]) === null){
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(["message" => "gameJam not found"]);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
$registration = Registration::where('game_jam_id', $gameJam->id)->where("group_id", $group->id)->frist();
|
||||||
|
if ($registration === null) {
|
||||||
|
http_response_code(401);
|
||||||
|
echo json_encode(["message" => "group not registered for that game jam"]);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
//if statement to find out if the group have use all their keyWords
|
//if statement to find out if the group have use all their keyWords
|
||||||
if(KeyWord::where('group_id', $group->id)->count()<$group->group_amount){
|
if (KeyWord::where('registration_id', $registration->id)->count() < $registration->group_amount) {
|
||||||
|
|
||||||
//Make a new keyword[Only to be used if you need to make a new of something]
|
//Make a new keyword[Only to be used if you need to make a new of something]
|
||||||
$keyword = new KeyWord();
|
$keyword = new KeyWord();
|
||||||
|
@ -21,23 +36,23 @@ if (isLogin()) {
|
||||||
$keyword->key_word = $_POST['key_word'];
|
$keyword->key_word = $_POST['key_word'];
|
||||||
|
|
||||||
//Make foreign key from the groups table to the keyWords table
|
//Make foreign key from the groups table to the keyWords table
|
||||||
$keyword->group()->associate($group);
|
$keyword->registration()->associate($registration);
|
||||||
|
|
||||||
//Try to save it
|
//Try to save it
|
||||||
if(!$keyword->save()){
|
if (!$keyword->save()) {
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
}else{
|
} else {
|
||||||
http_response_code(201);
|
http_response_code(201);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
echo json_encode(["message" => "limited upload reached"]);
|
echo json_encode(["message" => "limited upload reached"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(["message" => "not login"]);
|
echo json_encode(["message" => "not login"]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once realpath(dirname(__FILE__) ."/../../bootstrap.php");
|
require_once realpath(dirname(__FILE__) . "/../../bootstrap.php");
|
||||||
|
|
||||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
Capsule::schema()->create("admin_users", function (Blueprint $table){
|
Capsule::schema()->create("admin_users", function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->string("user_name");
|
$table->string("user_name");
|
||||||
$table->string("password");
|
$table->string("password");
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
//require bootstrap aka our database connection
|
//require bootstrap aka our database connection
|
||||||
require_once realpath(dirname(__FILE__) ."/../../bootstrap.php");
|
require_once realpath(dirname(__FILE__) . "/../../bootstrap.php");
|
||||||
|
|
||||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
//Create game_data table with the rows as id, gameLink, isWebBased and timestamp
|
//Create game_data table with the rows as id, gameLink, isWebBased and timestamp
|
||||||
Capsule::schema()->create("game_data", function (Blueprint $table){
|
Capsule::schema()->create("game_data", function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->string('game_name');
|
$table->string('game_name');
|
||||||
$table->string("game_link");
|
$table->string("game_link");
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
//require bootstrap aka our database connection
|
//require bootstrap aka our database connection
|
||||||
require_once realpath(dirname(__FILE__) ."/../../bootstrap.php");
|
require_once realpath(dirname(__FILE__) . "/../../bootstrap.php");
|
||||||
|
|
||||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
//Create game_jams table with the rows as id, name, startTime, endTime, keyWord, description and timestamp
|
//Create game_jams table with the rows as id, name, startTime, endTime, keyWord, description and timestamp
|
||||||
Capsule::schema()->create("game_jams", function (Blueprint $table){
|
Capsule::schema()->create("game_jams", function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->string("name");
|
$table->string("name");
|
||||||
$table->dateTime("start_time");
|
$table->dateTime("start_time");
|
||||||
|
|
|
@ -1,17 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
//require bootstrap aka our database connection
|
//require bootstrap aka our database connection
|
||||||
require_once realpath(dirname(__FILE__) ."/../../bootstrap.php");
|
require_once realpath(dirname(__FILE__) . "/../../bootstrap.php");
|
||||||
|
|
||||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
//Create groups table with the rows as id, groupName, groupAmount, fkGameJam, votes, fkPassword, fkGameData and timestamp
|
//Create groups table with the rows as id, groupName, groupAmount, fkGameJam, votes, fkPassword, fkGameData and timestamp
|
||||||
Capsule::schema()->create("groups", function (Blueprint $table){
|
Capsule::schema()->create("groups", function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->string("group_name");
|
$table->string("group_name");
|
||||||
$table->integer("group_amount");
|
|
||||||
$table->foreignId("game_jam_id")->constrained("game_jams");
|
|
||||||
$table->foreignId("game_data_id")->nullable()->constrained("game_data");
|
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
//require bootstrap aka our database connection
|
//require bootstrap aka our database connection
|
||||||
require_once realpath(dirname(__FILE__) ."/../../bootstrap.php");
|
require_once realpath(dirname(__FILE__) . "/../../bootstrap.php");
|
||||||
|
|
||||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
//Create key_words table with the rows as id, keyWord, fkGroup and timestamp
|
//Create key_words table with the rows as id, keyWord, fkGroup and timestamp
|
||||||
Capsule::schema()->create("key_words", function (Blueprint $table){
|
Capsule::schema()->create("key_words", function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->string('key_word');
|
$table->string('key_word');
|
||||||
$table->foreignId("group_id")->constrained("groups");
|
$table->foreignId("registrations_id")->constrained("registrations");
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
//require bootstrap aka our database connection
|
//require bootstrap aka our database connection
|
||||||
require_once realpath(dirname(__FILE__) ."/../../bootstrap.php");
|
require_once realpath(dirname(__FILE__) . "/../../bootstrap.php");
|
||||||
|
|
||||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
//Create password table with the rows as id, password, rememberToken and timestamps
|
//Create password table with the rows as id, password, rememberToken and timestamps
|
||||||
Capsule::schema()->create("passwords", function (Blueprint $table){
|
Capsule::schema()->create("passwords", function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->foreignId("group_id")->constrained("groups");
|
$table->foreignId("group_id")->constrained("groups");
|
||||||
$table->string('password');
|
$table->string('password');
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
//require bootstrap aka our database connection
|
||||||
|
require_once realpath(dirname(__FILE__) . "/../../bootstrap.php");
|
||||||
|
|
||||||
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
Capsule::schema()->create("registrations", function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId("group_id")->constrained("groups");
|
||||||
|
$table->integer("group_amount");
|
||||||
|
$table->foreignId("game_jam_id")->constrained("game_jams");
|
||||||
|
$table->foreignId("game_data_id")->unique()->nullable()->constrained("game_data");
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
|
@ -1,14 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
require_once realpath(dirname(__FILE__) ."/../../bootstrap.php");
|
require_once realpath(dirname(__FILE__) . "/../../bootstrap.php");
|
||||||
|
|
||||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
|
||||||
Capsule::schema()->create("votes", function (Blueprint $table){
|
Capsule::schema()->create("votes", function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->foreignId("group_id")->constrained("groups");
|
|
||||||
$table->tinyInteger("points");
|
$table->tinyInteger("points");
|
||||||
$table->text("comment")->nullable();
|
$table->text("comment")->nullable();
|
||||||
|
$table->foreignId("game_data_id")->constrained("game_data");
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
|
@ -17,6 +17,7 @@ require "GameJam.php"; //GameJam has no foreign key
|
||||||
require "GameData.php"; //GameData has no foreign key
|
require "GameData.php"; //GameData has no foreign key
|
||||||
require "Group.php"; //Group has foreign keys to the GameJam, GameData and Password tables hence we create it as one of the last tables in the database
|
require "Group.php"; //Group has foreign keys to the GameJam, GameData and Password tables hence we create it as one of the last tables in the database
|
||||||
require "Password.php"; //Password has no foreign key
|
require "Password.php"; //Password has no foreign key
|
||||||
|
require "Registration.php";
|
||||||
require "KeyWord.php"; //Group has foreign keys to the Group
|
require "KeyWord.php"; //Group has foreign keys to the Group
|
||||||
require "Vote.php";
|
require "Vote.php";
|
||||||
require "AdminUser.php";
|
require "AdminUser.php";
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Backend\Models;
|
namespace Backend\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
|
|
||||||
class AdminUser extends Eloquent
|
class AdminUser extends Eloquent
|
||||||
{
|
{
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
|
@ -9,5 +11,4 @@ class AdminUser extends Eloquent
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,14 +1,22 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Backend\Models;
|
namespace Backend\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
|
|
||||||
class GameData extends Eloquent
|
class GameData extends Eloquent
|
||||||
{
|
{
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'game_name', 'game_link', 'is_web_Based', 'description' , "img"
|
'game_name', 'game_link', 'is_web_Based', 'description', "img"
|
||||||
];
|
];
|
||||||
|
|
||||||
public function group(){
|
public function registration()
|
||||||
return $this->hasOne(Group::class);
|
{
|
||||||
|
return $this->hasOne(Registration::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function votes()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Vote::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Backend\Models;
|
namespace Backend\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
class GameJam extends Eloquent{
|
|
||||||
|
|
||||||
protected $fillable =[
|
class GameJam extends Eloquent
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
'name',
|
'name',
|
||||||
'start_time',
|
'start_time',
|
||||||
'end_time',
|
'end_time',
|
||||||
|
@ -13,11 +16,10 @@ class GameJam extends Eloquent{
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
public function group(){
|
public function registrations()
|
||||||
return $this->hasMany(Group::class);
|
{
|
||||||
}
|
return $this->hasMany(Registration::class);
|
||||||
public function hasVoted(){
|
|
||||||
return $this->hasMany(hasVoted::class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,26 +1,24 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Backend\Models;
|
namespace Backend\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
|
|
||||||
class Group extends Eloquent
|
class Group extends Eloquent
|
||||||
{
|
{
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'group_name', 'group_amount', 'votes'
|
'group_name', 'group_amount', 'votes'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function gameJam(){
|
|
||||||
return $this->belongsTo(GameJam::class);
|
public function password()
|
||||||
}
|
{
|
||||||
public function keyWord(){
|
|
||||||
return $this->hasMany(KeyWord::class);
|
|
||||||
}
|
|
||||||
public function gameData(){
|
|
||||||
return $this->belongsTo(GameData::class);
|
|
||||||
}
|
|
||||||
public function password(){
|
|
||||||
return $this->hasOne(Password::class);
|
return $this->hasOne(Password::class);
|
||||||
}
|
}
|
||||||
public function vote(){
|
|
||||||
return $this->hasMany(Vote::class);
|
public function registrations()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Registration::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Backend\Models;
|
namespace Backend\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
class KeyWord extends Eloquent{
|
|
||||||
protected $fillable =[
|
class KeyWord extends Eloquent
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
'key_word'
|
'key_word'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
public function group(){
|
public function registration()
|
||||||
return $this->belongsTo(Group::class);
|
{
|
||||||
|
return $this->belongsTo(Registration::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,13 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Backend\Models;
|
namespace Backend\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
class Password extends Eloquent{
|
|
||||||
protected $fillable =[
|
class Password extends Eloquent
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
'password', 'remember_token'
|
'password', 'remember_token'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
public function group(){
|
public function group()
|
||||||
|
{
|
||||||
return $this->belongsTo(Group::class);
|
return $this->belongsTo(Group::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Backend\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
|
|
||||||
|
class Registration extends Eloquent
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'group_amount'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
public function group()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Group::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function gameJam()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(GameJam::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function keyWords()
|
||||||
|
{
|
||||||
|
return $this->hasMany(KeyWord::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function gameData()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(GameData::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -11,9 +11,9 @@ class Vote extends Eloquent
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
public function group()
|
public function gameDate()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Group::class);
|
return $this->belongsTo(GameData::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue