test
This commit is contained in:
parent
00f6020dbc
commit
4f2cb208fd
|
@ -13,7 +13,7 @@ if (isset($_GET['gameDataId'])) {
|
||||||
$registrationIds = Registration::where("group_id", $_GET['groupId'])->pluck("game_data_id")->toArray();
|
$registrationIds = Registration::where("group_id", $_GET['groupId'])->pluck("game_data_id")->toArray();
|
||||||
$openGameDataStream = GameData::whereIn("id", $registrationIds)->get();
|
$openGameDataStream = GameData::whereIn("id", $registrationIds)->get();
|
||||||
} elseif (isset($_GET['gameJamId'])) {
|
} elseif (isset($_GET['gameJamId'])) {
|
||||||
$gameDataIds = Group::where("game_jam_id", $_GET['gameJamId'])->pluck("game_data_id")->toArray();
|
$gameDataIds = Registration::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();
|
||||||
|
|
|
@ -38,19 +38,30 @@ if (isLogin()) {
|
||||||
|
|
||||||
$gameData->game_name = $title;
|
$gameData->game_name = $title;
|
||||||
if (isset($gameData) && $gameFileError === 0) {
|
if (isset($gameData) && $gameFileError === 0) {
|
||||||
unlink("../../Games/" . $gameData->game_link);
|
if(unlink("../../Games/" . $gameData->game_link)){
|
||||||
$gameData->game_link = ZipFileHandler($gameFileName, $gameFileTmp);
|
$gameData->game_link = ZipFileHandler($gameFileName, $gameFileTmp);
|
||||||
|
}else{
|
||||||
|
http_response_code(500);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$gameData->description = $desc;
|
$gameData->description = $desc;
|
||||||
if (isset($thumbnail) && $thumbnailFileError === 0) {
|
if (isset($thumbnail) && $thumbnailFileError === 0) {
|
||||||
unlink("../../../Frontend/images/" . $gameData->img);
|
|
||||||
|
if(unlink("../../../Frontend/images/" . $gameData->img)){
|
||||||
$gameData->img = imagesFileHandler($thumbnailFileName, $thumbnailFileTmp);
|
$gameData->img = imagesFileHandler($thumbnailFileName, $thumbnailFileTmp);
|
||||||
|
}else{
|
||||||
|
http_response_code(500);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$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(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -23,7 +23,7 @@ if (isLogin()) {
|
||||||
echo json_encode(["message" => "gameJam not found"]);
|
echo json_encode(["message" => "gameJam not found"]);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
$registration = Registration::where('game_jam_id', $gameJam->id)->where("group_id", $group->id)->frist();
|
$registration = Registration::where('game_jam_id', $gameJam->id)->where("group_id", $group->id)->first();
|
||||||
if ($registration === null) {
|
if ($registration === null) {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(["message" => "group not registered for that game jam"]);
|
echo json_encode(["message" => "group not registered for that game jam"]);
|
||||||
|
|
|
@ -6,12 +6,12 @@ use \Backend\Models\KeyWord;
|
||||||
use \Backend\Models\GameJam;
|
use \Backend\Models\GameJam;
|
||||||
use Backend\Models\Registration;
|
use Backend\Models\Registration;
|
||||||
|
|
||||||
if (!isAdmin()) {
|
if (isAdmin()) {
|
||||||
if (isset($_GET['genKeyWord'])) {
|
if (isset($_GET['gameJamId'])) {
|
||||||
$gameJamId = $_GET['gameJamId'];
|
$gameJamId = $_GET['gameJamId'];
|
||||||
$game_jam = GameJam::find($gameJamId);
|
$game_jam = GameJam::find($gameJamId);
|
||||||
$all_registration_in_game_jam_id = Registration::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_registration_in_game_jam_id)->inRandomOrder()->take(6)->get();
|
$find_all_keywords = KeyWord::whereIn("registration_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);
|
||||||
|
|
|
@ -7,20 +7,20 @@ use Backend\Models\Registration;
|
||||||
use Backend\Models\Group;
|
use Backend\Models\Group;
|
||||||
use Backend\Models\KeyWord;
|
use Backend\Models\KeyWord;
|
||||||
|
|
||||||
session_start();
|
|
||||||
|
|
||||||
if (isLogin()) {
|
if (isLogin()) {
|
||||||
if (isset($_POST['submitKeyWord'])) {
|
if (isset($_POST['submitKeyWord'])) {
|
||||||
//Find the group
|
//Find the group
|
||||||
$group = groupViaToken($_SESSION['token']);
|
$group = groupViaToken($_SESSION['token']);
|
||||||
|
|
||||||
if($gameJam = GameJam::find($_POST["gameJamId"]) === null){
|
if(!$gameJam = GameJam::find($_POST['gameJamId'])){
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
echo json_encode(["message" => "gameJam not found"]);
|
echo json_encode(["message" => "gameJam not found"]);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
$registration = Registration::where('game_jam_id', $gameJam->id)->where("group_id", $group->id)->frist();
|
//var_dump($gameJam);
|
||||||
if ($registration === null) {
|
|
||||||
|
$registration = Registration::where('game_jam_id', $gameJam->id)->where("group_id", $group->id)->first();
|
||||||
|
if (!$registration) {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(["message" => "group not registered for that game jam"]);
|
echo json_encode(["message" => "group not registered for that game jam"]);
|
||||||
exit();
|
exit();
|
||||||
|
@ -33,7 +33,7 @@ if (isLogin()) {
|
||||||
$keyword = new KeyWord();
|
$keyword = new KeyWord();
|
||||||
|
|
||||||
//Take the keyWord the user typed and set it equal to the keyword valuable
|
//Take the keyWord the user typed and set it equal to the keyword valuable
|
||||||
$keyword->key_word = $_POST['key_word'];
|
$keyword->key_word = $_POST['keyWord'];
|
||||||
|
|
||||||
//Make foreign key from the groups table to the keyWords table
|
//Make foreign key from the groups table to the keyWords table
|
||||||
$keyword->registration()->associate($registration);
|
$keyword->registration()->associate($registration);
|
||||||
|
|
|
@ -13,7 +13,8 @@ Capsule::schema()->create("game_jams", function (Blueprint $table) {
|
||||||
$table->dateTime("start_time");
|
$table->dateTime("start_time");
|
||||||
$table->dateTime("end_time");
|
$table->dateTime("end_time");
|
||||||
$table->string("key_word")->nullable();
|
$table->string("key_word")->nullable();
|
||||||
$table->text("description")->nullable();
|
$table->text("description");
|
||||||
|
$table->boolean("is_finished")->default(false);
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ use Illuminate\Support\Facades\Schema;
|
||||||
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("registrations_id")->constrained("registrations");
|
$table->foreignId("registration_id")->constrained("registrations");
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,8 @@ class GameJam extends Eloquent
|
||||||
'start_time',
|
'start_time',
|
||||||
'end_time',
|
'end_time',
|
||||||
'key_word',
|
'key_word',
|
||||||
'description'
|
'description',
|
||||||
|
'is_finished'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue