Compare commits
No commits in common. "921c1ed876dd514494a99f873e21744fd1ce880f" and "43d47fb2aa80d041fa724341955327868f9fcf9d" have entirely different histories.
921c1ed876
...
43d47fb2aa
|
@ -13,12 +13,9 @@ if (isset($_GET['gameDataId'])) {
|
|||
$registrationIds = Registration::where("group_id", $_GET['groupId'])->pluck("game_data_id")->toArray();
|
||||
$openGameDataStream = GameData::whereIn("id", $registrationIds)->get();
|
||||
} elseif (isset($_GET['gameJamId'])) {
|
||||
$gameDataIds = Registration::where("game_jam_id", $_GET['gameJamId'])->pluck("game_data_id")->toArray();
|
||||
$gameDataIds = Group::where("game_jam_id", $_GET['gameJamId'])->pluck("game_data_id")->toArray();
|
||||
$openGameDataStream = GameData::whereIn("id", $gameDataIds)->get();
|
||||
} elseif (isset($_GET["newest"])){
|
||||
$openGameDataStream = GameData::all()->sortByDesc("updated_at")->take($_GET["newest"]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$openGameDataStream = GameData::all();
|
||||
}
|
||||
|
||||
|
|
|
@ -38,30 +38,19 @@ if (isLogin()) {
|
|||
|
||||
$gameData->game_name = $title;
|
||||
if (isset($gameData) && $gameFileError === 0) {
|
||||
if(unlink("../../Games/" . $gameData->game_link)){
|
||||
$gameData->game_link = ZipFileHandler($gameFileName, $gameFileTmp);
|
||||
}else{
|
||||
http_response_code(500);
|
||||
exit();
|
||||
}
|
||||
|
||||
unlink("../../Games/" . $gameData->game_link);
|
||||
$gameData->game_link = ZipFileHandler($gameFileName, $gameFileTmp);
|
||||
}
|
||||
$gameData->description = $desc;
|
||||
if (isset($thumbnail) && $thumbnailFileError === 0) {
|
||||
|
||||
if(unlink("../../../Frontend/images/" . $gameData->img)){
|
||||
$gameData->img = imagesFileHandler($thumbnailFileName, $thumbnailFileTmp);
|
||||
}else{
|
||||
http_response_code(500);
|
||||
exit();
|
||||
}
|
||||
|
||||
unlink("../../../Frontend/images/" . $gameData->img);
|
||||
$gameData->img = imagesFileHandler($thumbnailFileName, $thumbnailFileTmp);
|
||||
}
|
||||
$gameData->is_web_Based = $isWebBased;
|
||||
if (!$gameData->save()) {
|
||||
http_response_code(500);
|
||||
} else {
|
||||
http_response_code(200);
|
||||
http_response_code(201);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
|
@ -23,7 +23,7 @@ if (isLogin()) {
|
|||
echo json_encode(["message" => "gameJam not found"]);
|
||||
exit();
|
||||
}
|
||||
$registration = Registration::where('game_jam_id', $gameJam->id)->where("group_id", $group->id)->first();
|
||||
$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"]);
|
||||
|
|
|
@ -11,20 +11,7 @@ use Backend\Models\GameJam;
|
|||
|
||||
if (isset($_GET['gameJamId'])) {
|
||||
$dbValue = GameJam::find($_GET['gameJamId']);
|
||||
}elseif (isset($_GET['hasEnded'])){
|
||||
$hasEnded = $_GET['hasEnded'];
|
||||
if($hasEnded == 0 OR $hasEnded == 1){
|
||||
if ($hasEnded){
|
||||
$dbValue = GameJam::where("is_finished",1)->get();
|
||||
}else{
|
||||
$dbValue = GameJam::where("is_finished",0)->get();
|
||||
}
|
||||
}
|
||||
else{
|
||||
$dbValue = GameJam::all();
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$dbValue = GameJam::all();
|
||||
}
|
||||
|
||||
|
|
|
@ -6,12 +6,12 @@ use \Backend\Models\KeyWord;
|
|||
use \Backend\Models\GameJam;
|
||||
use Backend\Models\Registration;
|
||||
|
||||
if (isAdmin()) {
|
||||
if (isset($_GET['gameJamId'])) {
|
||||
if (!isAdmin()) {
|
||||
if (isset($_GET['genKeyWord'])) {
|
||||
$gameJamId = $_GET['gameJamId'];
|
||||
$game_jam = GameJam::find($gameJamId);
|
||||
$all_registration_in_game_jam_id = Registration::where("game_jam_id", $game_jam->id)->pluck("id")->toArray();
|
||||
$find_all_keywords = KeyWord::whereIn("registration_id", $all_registration_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;
|
||||
if (!$game_jam->save()) {
|
||||
http_response_code(500);
|
||||
|
|
|
@ -7,20 +7,20 @@ use Backend\Models\Registration;
|
|||
use Backend\Models\Group;
|
||||
use Backend\Models\KeyWord;
|
||||
|
||||
session_start();
|
||||
|
||||
if (isLogin()) {
|
||||
if (isset($_POST['submitKeyWord'])) {
|
||||
//Find the group
|
||||
$group = groupViaToken($_SESSION['token']);
|
||||
|
||||
if(!$gameJam = GameJam::find($_POST['gameJamId'])){
|
||||
if($gameJam = GameJam::find($_POST["gameJamId"]) === null){
|
||||
http_response_code(400);
|
||||
echo json_encode(["message" => "gameJam not found"]);
|
||||
exit();
|
||||
}
|
||||
//var_dump($gameJam);
|
||||
|
||||
$registration = Registration::where('game_jam_id', $gameJam->id)->where("group_id", $group->id)->first();
|
||||
if (!$registration) {
|
||||
$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();
|
||||
|
@ -33,7 +33,7 @@ if (isLogin()) {
|
|||
$keyword = new KeyWord();
|
||||
|
||||
//Take the keyWord the user typed and set it equal to the keyword valuable
|
||||
$keyword->key_word = $_POST['keyWord'];
|
||||
$keyword->key_word = $_POST['key_word'];
|
||||
|
||||
//Make foreign key from the groups table to the keyWords table
|
||||
$keyword->registration()->associate($registration);
|
||||
|
|
|
@ -13,8 +13,7 @@ Capsule::schema()->create("game_jams", function (Blueprint $table) {
|
|||
$table->dateTime("start_time");
|
||||
$table->dateTime("end_time");
|
||||
$table->string("key_word")->nullable();
|
||||
$table->text("description");
|
||||
$table->boolean("is_finished")->default(false);
|
||||
$table->text("description")->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ use Illuminate\Support\Facades\Schema;
|
|||
Capsule::schema()->create("key_words", function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('key_word');
|
||||
$table->foreignId("registration_id")->constrained("registrations");
|
||||
$table->foreignId("registrations_id")->constrained("registrations");
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
|
|
|
@ -12,8 +12,7 @@ class GameJam extends Eloquent
|
|||
'start_time',
|
||||
'end_time',
|
||||
'key_word',
|
||||
'description',
|
||||
'is_finished'
|
||||
'description'
|
||||
];
|
||||
|
||||
|
||||
|
|
|
@ -183,43 +183,11 @@
|
|||
</form>
|
||||
</div>
|
||||
<!-- Opret game jam slut -->
|
||||
<hr class="GradientDivide">
|
||||
<!-- updater game jam start -->
|
||||
<h5>updater Game Jam</h5>
|
||||
<form id='UpdateGameJam' method='post'>
|
||||
<section id="game-jame-update-drop-down">
|
||||
|
||||
</section>
|
||||
|
||||
<section id="game-jame-update">
|
||||
|
||||
<input type="hidden" name="gameJamId" required/>
|
||||
<label for='UGameJamTitle'>Game Jam tittle</label>
|
||||
<input type='text' id='UGameJamTitle' required value="" name="gameJamName"/>
|
||||
<label for="UStartDate">Start dag</label>
|
||||
<input type='date' id='UStartDate' required name="startDate"/>
|
||||
<label for="UStartTime">Start tid</label>
|
||||
<input type="time" id="UStartTime" required name="startTime"/>
|
||||
<label for="UEndDate">Slut dag</label>
|
||||
<input type="date" id="UEndDate" required name="endDate"/>
|
||||
<label for="UEndTime">slut tid</label>
|
||||
<input type="time" id="UEndTime" required name="endTime"/>
|
||||
<label for="UKeyWord">Emne(Ikke obligatorisk)</label>
|
||||
<input type="text" id="UKeyWord" name="keyWord"/>
|
||||
<label for="UDescription">Beskrivelse</label>
|
||||
<input type="text" id="UDescription" required name="description"/>
|
||||
<input type="submit" value="set" name="updateGameJam">
|
||||
|
||||
|
||||
</section>
|
||||
</form>
|
||||
|
||||
|
||||
<!-- Body scripts -->
|
||||
<script src="../Javascript/OverlayScrollbar.js"></script>
|
||||
<!--<script src="../Javascript/AddEvent.js"></script>-->
|
||||
<script src="../Javascript/AddGameJam.js"></script>
|
||||
<!-- Body scripts end -->
|
||||
<script src="../Javascript/AdminPageScript.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
async function getGamejames(id = 0) {
|
||||
if(id !== 0){
|
||||
var url = "http://localhost/Game-Jaming/Backend/Controllers/GameJam/GetGameJam.php?gameJamId="+id;
|
||||
}else {
|
||||
var url = "http://localhost/Game-Jaming/Backend/Controllers/GameJam/GetGameJam.php";
|
||||
}
|
||||
let response = await axios.get(url);
|
||||
return response.data.data
|
||||
}
|
||||
async function updateGameDropdown() {
|
||||
var UGJDropDown = document.getElementById("game-jame-update-drop-down");
|
||||
var jsondata;
|
||||
var UGJDropDownHtml = "<label for='gameJamesDropdown'>vælge et game Jam:</label>"+
|
||||
"<select onchange='changeGameJamUpdate()' id='gameJamesDropdown' name='gameJamId'>";
|
||||
|
||||
await getGamejames().then((data) =>
|
||||
data.forEach(val =>
|
||||
UGJDropDownHtml += " <option value='"+val.id+"'>"+val.name+"</option>"
|
||||
));
|
||||
|
||||
UGJDropDownHtml += "</select>";
|
||||
//console.log(UGJDropDownHtml);
|
||||
UGJDropDown.innerHTML = UGJDropDownHtml;
|
||||
changeGameJamUpdate()
|
||||
|
||||
}
|
||||
|
||||
|
||||
async function changeGameJamUpdate() {
|
||||
var val = document.getElementById("gameJamesDropdown").value;
|
||||
await getGamejames(parseInt(val)).then(function (data) {
|
||||
document.getElementById("UGameJamTitle").value = data.name;
|
||||
var startDateTime = data.start_time.split(" ");
|
||||
document.getElementById("UStartDate").value = startDateTime[0];
|
||||
document.getElementById("UStartTime").value = startDateTime[1];
|
||||
var endDateTime = data.end_time.split(" ");
|
||||
document.getElementById("UEndDate").value = endDateTime[0];
|
||||
document.getElementById("UEndTime").value = endDateTime[1];
|
||||
document.getElementById("UKeyWord").value = data.key_word;
|
||||
document.getElementById("UDescription").value = data.description;
|
||||
}
|
||||
);
|
||||
}
|
||||
updateGameDropdown();
|
||||
|
||||
|
Loading…
Reference in New Issue