fixed some stuff

This commit is contained in:
neerholt
2021-03-11 13:20:10 +01:00
parent 0e343cb46e
commit 1d1606ff13
8 changed files with 72 additions and 9 deletions
@@ -1 +1,22 @@
<?php
require_once "../../../bootstrap.php";
require_once "../Admin/Admin.php";
use Backend\Models\Group;
use \Backend\Models\KeyWord;
use \Backend\Models\GameJam;
use \Illuminate\Support\Collection;
if (!isAdmin()){
if(isset($_POST['genKeyWord'])){
$gameJamId = $_POST['gameJamId'];
$game_jam = GameJam::find($gameJamId);
$all_group_in_game_jam_id = Group::where("game_jam_id", $game_jam->id)->pluck("id")->toArray();
$find_all_keywords = KeyWord::whereIn("group_id", $all_group_in_game_jam_id)->inRandomOrder()->get();
$game_jam->key_word = $find_all_keywords->first()->key_word;
$game_jam->save();
header('Content-Type: application/json;charset=UTF-8');
echo $find_all_keywords->pluck("key_word")->toJson(JSON_PRETTY_PRINT);
}
}
@@ -1,5 +1,6 @@
<?php
require "../../bootstrap.php";
require "../../../bootstrap.php";
require_once "../Group/Group.php";
use Backend\Models\Group;
use Backend\Models\KeyWord;
@@ -8,10 +9,10 @@ session_start();
if (session_status() === PHP_SESSION_ACTIVE) {
if(isset($_POST['submitKeyWord'])){
//Find the group id
$group = Group::find($_SESSION['groupId']);
$group = groupViaToken($_SESSION['token']);
//if statement to find out if the group have use all their keyWords
if(KeyWord::where('group_id', $group->id)->count()<$group->groupAmount){
if(KeyWord::where('group_id', $group->id)->count()<$group->group_amount){
//Make a new keyword[Only to be used if you need to make a new of something]
$keyword = new KeyWord();
@@ -24,9 +25,9 @@ if (session_status() === PHP_SESSION_ACTIVE) {
//Try to save it
if(!$keyword->save()){
header("location: ../Frontend/index.php?created=failed");
header("location: ../../../Frontend/index.php?created=failed");
}else{
header("location: ../Frontend/index.php?created=success");
header("location:../../../Frontend/index.php?created=success");
}
}