registration controllers update
This commit is contained in:
parent
995cec56b1
commit
48b9f532a4
|
@ -1,13 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Backend\Models\GameData;
|
||||
use Backend\Models\Vote;
|
||||
use \Backend\Models\Registration;
|
||||
|
||||
require_once "../../../bootstrap.php";
|
||||
require_once "../Group/Group.php";
|
||||
|
||||
if (isLogin()) {
|
||||
|
||||
$gameDate = GameData::find($_GET[]);
|
||||
if(!$gameDate){
|
||||
http_response_code(400);
|
||||
echo json_encode(["message" => "game data not found"]);
|
||||
exit();
|
||||
}
|
||||
$reg = Registration::where("game_data_id", $gameDate->id)->first();
|
||||
$group = groupViaToken($_SESSION['token']);
|
||||
if($reg->group_id !== $group->id){
|
||||
http_response_code(401);
|
||||
echo json_encode(["message" => "group not own game data"]);
|
||||
}
|
||||
|
||||
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('game_data_id',$gameDate->id)->get()->jsonSerialize()));
|
||||
|
||||
} else {
|
||||
http_response_code(401);
|
||||
|
|
|
@ -1 +1,32 @@
|
|||
<?php
|
||||
require_once "../../../bootstrap.php";
|
||||
require_once "../Group/Group.php";
|
||||
|
||||
use Backend\Models\Registration;
|
||||
|
||||
if(isLogin()){
|
||||
if(isset($_POST['newReg'])){
|
||||
$group = groupViaToken($_SESSION['token']);
|
||||
$gameJam = \Backend\Models\GameJam::find($_POST["gameJamId"]);
|
||||
if(Registration::where("group_id", $group->id)->where("game_jam_id", $gameJam->id)->count() === 0){
|
||||
$reg = new Registration();
|
||||
$reg->group_amount = $_POST["groupAmount"];
|
||||
$reg->group()->associate($group);
|
||||
$reg->gameJam()->associate($gameJam);
|
||||
if($reg->save()){
|
||||
http_response_code(201);
|
||||
}else{
|
||||
http_response_code(500);
|
||||
}
|
||||
}else {
|
||||
http_response_code(400);
|
||||
echo json_encode(["message" => "already registered"]);
|
||||
}
|
||||
}else {
|
||||
http_response_code(400);
|
||||
}
|
||||
}else{
|
||||
http_response_code(401);
|
||||
echo json_encode(["message" => "is not login"]);
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1,27 @@
|
|||
<?php
|
||||
require_once "../../../bootstrap.php";
|
||||
require_once "../Group/Group.php";
|
||||
|
||||
use Backend\Models\Registration;
|
||||
|
||||
if(isLogin()){
|
||||
if(isset($_POST['updateReg'])){
|
||||
if($reg = Registration::where("group_id", $_POST["groupId"])->where("game_jam_id", $_POST["gameJamId"])->first()){
|
||||
$reg->group_amount = $_POST["groupAmount"];
|
||||
if($reg->save()){
|
||||
http_response_code(200);
|
||||
}else{
|
||||
http_response_code(500);
|
||||
}
|
||||
}else{
|
||||
http_response_code(400);
|
||||
echo json_encode(["message" => "registration does not exits"]);
|
||||
}
|
||||
|
||||
}else{
|
||||
http_response_code(400);
|
||||
}
|
||||
}else{
|
||||
http_response_code(401);
|
||||
echo json_encode(["message" => "is not login"]);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
"ext-mysqli": "*",
|
||||
"ext-sqlite3": "*",
|
||||
"ext-fileinfo": "*",
|
||||
"ext-json": "*",
|
||||
"twbs/bootstrap": "5.0.0-beta3"
|
||||
},
|
||||
"autoload": {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "a595c493fc068e54510775d5cd53d649",
|
||||
"content-hash": "e0289598393b91834d5fbd72b92a029a",
|
||||
"packages": [
|
||||
{
|
||||
"name": "doctrine/inflector",
|
||||
|
@ -103,16 +103,16 @@
|
|||
},
|
||||
{
|
||||
"name": "illuminate/collections",
|
||||
"version": "v8.37.0",
|
||||
"version": "v8.38.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/collections.git",
|
||||
"reference": "591e31015a8b0731708c54411cb52d50a00b2bc3"
|
||||
"reference": "21690cd5591f2d42d792e5e4a687f9beba829f1d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/collections/zipball/591e31015a8b0731708c54411cb52d50a00b2bc3",
|
||||
"reference": "591e31015a8b0731708c54411cb52d50a00b2bc3",
|
||||
"url": "https://api.github.com/repos/illuminate/collections/zipball/21690cd5591f2d42d792e5e4a687f9beba829f1d",
|
||||
"reference": "21690cd5591f2d42d792e5e4a687f9beba829f1d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -153,11 +153,11 @@
|
|||
"issues": "https://github.com/laravel/framework/issues",
|
||||
"source": "https://github.com/laravel/framework"
|
||||
},
|
||||
"time": "2021-04-01T13:26:52+00:00"
|
||||
"time": "2021-04-14T11:48:08+00:00"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/container",
|
||||
"version": "v8.37.0",
|
||||
"version": "v8.38.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/container.git",
|
||||
|
@ -208,7 +208,7 @@
|
|||
},
|
||||
{
|
||||
"name": "illuminate/contracts",
|
||||
"version": "v8.37.0",
|
||||
"version": "v8.38.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/contracts.git",
|
||||
|
@ -256,16 +256,16 @@
|
|||
},
|
||||
{
|
||||
"name": "illuminate/database",
|
||||
"version": "v8.37.0",
|
||||
"version": "v8.38.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/database.git",
|
||||
"reference": "a9d9c78c705bc64e92a61c33453ebbcad6dd5f29"
|
||||
"reference": "03c0525b693587f877f4d80dcc55597528c98fc0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/database/zipball/a9d9c78c705bc64e92a61c33453ebbcad6dd5f29",
|
||||
"reference": "a9d9c78c705bc64e92a61c33453ebbcad6dd5f29",
|
||||
"url": "https://api.github.com/repos/illuminate/database/zipball/03c0525b693587f877f4d80dcc55597528c98fc0",
|
||||
"reference": "03c0525b693587f877f4d80dcc55597528c98fc0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -320,11 +320,11 @@
|
|||
"issues": "https://github.com/laravel/framework/issues",
|
||||
"source": "https://github.com/laravel/framework"
|
||||
},
|
||||
"time": "2021-04-13T13:40:36+00:00"
|
||||
"time": "2021-04-17T17:53:05+00:00"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/macroable",
|
||||
"version": "v8.37.0",
|
||||
"version": "v8.38.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/macroable.git",
|
||||
|
@ -370,16 +370,16 @@
|
|||
},
|
||||
{
|
||||
"name": "illuminate/support",
|
||||
"version": "v8.37.0",
|
||||
"version": "v8.38.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/support.git",
|
||||
"reference": "074a9b7adefcdd7108e19faa96bc9dacfe922062"
|
||||
"reference": "735391f31e145aad4f7aff3d9736ef70452dd1fe"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/support/zipball/074a9b7adefcdd7108e19faa96bc9dacfe922062",
|
||||
"reference": "074a9b7adefcdd7108e19faa96bc9dacfe922062",
|
||||
"url": "https://api.github.com/repos/illuminate/support/zipball/735391f31e145aad4f7aff3d9736ef70452dd1fe",
|
||||
"reference": "735391f31e145aad4f7aff3d9736ef70452dd1fe",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -434,7 +434,7 @@
|
|||
"issues": "https://github.com/laravel/framework/issues",
|
||||
"source": "https://github.com/laravel/framework"
|
||||
},
|
||||
"time": "2021-04-11T23:26:41+00:00"
|
||||
"time": "2021-04-15T11:51:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nesbot/carbon",
|
||||
|
@ -1686,7 +1686,8 @@
|
|||
"platform": {
|
||||
"ext-mysqli": "*",
|
||||
"ext-sqlite3": "*",
|
||||
"ext-fileinfo": "*"
|
||||
"ext-fileinfo": "*",
|
||||
"ext-json": "*"
|
||||
},
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.0.0"
|
||||
|
|
Loading…
Reference in New Issue