Fixed keyword upload error and you are now only able to upload the same amount of keywords as there group members

This commit is contained in:
neerholt 2021-03-08 10:03:06 +01:00
parent 93b9411c99
commit 04372b3539
2 changed files with 65 additions and 52 deletions

View File

@ -4,15 +4,33 @@ use Backend\Models\Group;
use Backend\Models\KeyWord; use Backend\Models\KeyWord;
if(isset($_POST['submitKeyWord'])){ if(isset($_POST['submitKeyWord'])){
//Find the group id
$group = Group::find($_POST['group_id']);
//if statement to find out if the group have use all their keyWords
if(KeyWord::where('group_id', $group->id)->count()<$group->groupAmount){
//Make a new keyword[Only to be used if you need to make a new of something]
$keyword = new KeyWord(); $keyword = new KeyWord();
//Take the keyWord the user typed and set it equal to the keyword valuable
$keyword->keyWord = $_POST['key_word']; $keyword->keyWord = $_POST['key_word'];
$keyword->group()->associate(Group::find($_POST['group_id'])); //Make foreign key from the groups table to the keyWords table
$keyword->group()->associate($group);
//Try to save it
if(!$keyword->save()){ if(!$keyword->save()){
return; header("location: ../Frontend/index.php?created=failed");
}else{
header("location: ../Frontend/index.php?created=success");
}
} }
//TODO make toast feedback
} }

87
composer.lock generated
View File

@ -103,7 +103,7 @@
}, },
{ {
"name": "illuminate/collections", "name": "illuminate/collections",
"version": "v8.30.0", "version": "v8.31.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/illuminate/collections.git", "url": "https://github.com/illuminate/collections.git",
@ -157,7 +157,7 @@
}, },
{ {
"name": "illuminate/container", "name": "illuminate/container",
"version": "v8.30.0", "version": "v8.31.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/illuminate/container.git", "url": "https://github.com/illuminate/container.git",
@ -208,7 +208,7 @@
}, },
{ {
"name": "illuminate/contracts", "name": "illuminate/contracts",
"version": "v8.30.0", "version": "v8.31.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/illuminate/contracts.git", "url": "https://github.com/illuminate/contracts.git",
@ -256,16 +256,16 @@
}, },
{ {
"name": "illuminate/database", "name": "illuminate/database",
"version": "v8.30.0", "version": "v8.31.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/illuminate/database.git", "url": "https://github.com/illuminate/database.git",
"reference": "a2be80ba829258b9b44fa43443aa81653604b931" "reference": "87dd6cee1eb159dfcba95bd1d2ed59d3f3244b36"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/illuminate/database/zipball/a2be80ba829258b9b44fa43443aa81653604b931", "url": "https://api.github.com/repos/illuminate/database/zipball/87dd6cee1eb159dfcba95bd1d2ed59d3f3244b36",
"reference": "a2be80ba829258b9b44fa43443aa81653604b931", "reference": "87dd6cee1eb159dfcba95bd1d2ed59d3f3244b36",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -320,11 +320,11 @@
"issues": "https://github.com/laravel/framework/issues", "issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework" "source": "https://github.com/laravel/framework"
}, },
"time": "2021-03-02T00:08:47+00:00" "time": "2021-03-04T13:08:15+00:00"
}, },
{ {
"name": "illuminate/macroable", "name": "illuminate/macroable",
"version": "v8.30.0", "version": "v8.31.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/illuminate/macroable.git", "url": "https://github.com/illuminate/macroable.git",
@ -370,16 +370,16 @@
}, },
{ {
"name": "illuminate/support", "name": "illuminate/support",
"version": "v8.30.0", "version": "v8.31.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/illuminate/support.git", "url": "https://github.com/illuminate/support.git",
"reference": "0f59c467c1b612122488a262e7f9fb32b30df36a" "reference": "978e64ffb68189b70fea77e4d401f43e88fa54ca"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/illuminate/support/zipball/0f59c467c1b612122488a262e7f9fb32b30df36a", "url": "https://api.github.com/repos/illuminate/support/zipball/978e64ffb68189b70fea77e4d401f43e88fa54ca",
"reference": "0f59c467c1b612122488a262e7f9fb32b30df36a", "reference": "978e64ffb68189b70fea77e4d401f43e88fa54ca",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -434,7 +434,7 @@
"issues": "https://github.com/laravel/framework/issues", "issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework" "source": "https://github.com/laravel/framework"
}, },
"time": "2021-02-26T13:17:27+00:00" "time": "2021-03-04T14:09:31+00:00"
}, },
{ {
"name": "nesbot/carbon", "name": "nesbot/carbon",
@ -531,27 +531,22 @@
}, },
{ {
"name": "psr/container", "name": "psr/container",
"version": "1.0.0", "version": "1.1.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/php-fig/container.git", "url": "https://github.com/php-fig/container.git",
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf",
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.0" "php": ">=7.2.0"
}, },
"type": "library", "type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Psr\\Container\\": "src/" "Psr\\Container\\": "src/"
@ -564,7 +559,7 @@
"authors": [ "authors": [
{ {
"name": "PHP-FIG", "name": "PHP-FIG",
"homepage": "http://www.php-fig.org/" "homepage": "https://www.php-fig.org/"
} }
], ],
"description": "Common Container Interface (PHP FIG PSR-11)", "description": "Common Container Interface (PHP FIG PSR-11)",
@ -578,9 +573,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/php-fig/container/issues", "issues": "https://github.com/php-fig/container/issues",
"source": "https://github.com/php-fig/container/tree/master" "source": "https://github.com/php-fig/container/tree/1.1.1"
}, },
"time": "2017-02-14T16:28:37+00:00" "time": "2021-03-05T17:36:06+00:00"
}, },
{ {
"name": "psr/simple-cache", "name": "psr/simple-cache",
@ -635,16 +630,16 @@
}, },
{ {
"name": "symfony/console", "name": "symfony/console",
"version": "v5.2.3", "version": "v5.2.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/console.git", "url": "https://github.com/symfony/console.git",
"reference": "89d4b176d12a2946a1ae4e34906a025b7b6b135a" "reference": "d6d0cc30d8c0fda4e7b213c20509b0159a8f4556"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/89d4b176d12a2946a1ae4e34906a025b7b6b135a", "url": "https://api.github.com/repos/symfony/console/zipball/d6d0cc30d8c0fda4e7b213c20509b0159a8f4556",
"reference": "89d4b176d12a2946a1ae4e34906a025b7b6b135a", "reference": "d6d0cc30d8c0fda4e7b213c20509b0159a8f4556",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -712,7 +707,7 @@
"terminal" "terminal"
], ],
"support": { "support": {
"source": "https://github.com/symfony/console/tree/v5.2.3" "source": "https://github.com/symfony/console/tree/v5.2.4"
}, },
"funding": [ "funding": [
{ {
@ -728,7 +723,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2021-01-28T22:06:19+00:00" "time": "2021-02-23T10:08:49+00:00"
}, },
{ {
"name": "symfony/polyfill-ctype", "name": "symfony/polyfill-ctype",
@ -1297,16 +1292,16 @@
}, },
{ {
"name": "symfony/string", "name": "symfony/string",
"version": "v5.2.3", "version": "v5.2.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/string.git", "url": "https://github.com/symfony/string.git",
"reference": "c95468897f408dd0aca2ff582074423dd0455122" "reference": "4e78d7d47061fa183639927ec40d607973699609"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/c95468897f408dd0aca2ff582074423dd0455122", "url": "https://api.github.com/repos/symfony/string/zipball/4e78d7d47061fa183639927ec40d607973699609",
"reference": "c95468897f408dd0aca2ff582074423dd0455122", "reference": "4e78d7d47061fa183639927ec40d607973699609",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1360,7 +1355,7 @@
"utf8" "utf8"
], ],
"support": { "support": {
"source": "https://github.com/symfony/string/tree/v5.2.3" "source": "https://github.com/symfony/string/tree/v5.2.4"
}, },
"funding": [ "funding": [
{ {
@ -1376,20 +1371,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2021-01-25T15:14:59+00:00" "time": "2021-02-16T10:20:28+00:00"
}, },
{ {
"name": "symfony/translation", "name": "symfony/translation",
"version": "v5.2.3", "version": "v5.2.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/translation.git", "url": "https://github.com/symfony/translation.git",
"reference": "c021864d4354ee55160ddcfd31dc477a1bc77949" "reference": "74b0353ab34ff4cca827a2cf909e325d96815e60"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/c021864d4354ee55160ddcfd31dc477a1bc77949", "url": "https://api.github.com/repos/symfony/translation/zipball/74b0353ab34ff4cca827a2cf909e325d96815e60",
"reference": "c021864d4354ee55160ddcfd31dc477a1bc77949", "reference": "74b0353ab34ff4cca827a2cf909e325d96815e60",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1406,7 +1401,7 @@
"symfony/yaml": "<4.4" "symfony/yaml": "<4.4"
}, },
"provide": { "provide": {
"symfony/translation-implementation": "2.0" "symfony/translation-implementation": "2.3"
}, },
"require-dev": { "require-dev": {
"psr/log": "~1.0", "psr/log": "~1.0",
@ -1453,7 +1448,7 @@
"description": "Provides tools to internationalize your application", "description": "Provides tools to internationalize your application",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"support": { "support": {
"source": "https://github.com/symfony/translation/tree/v5.2.3" "source": "https://github.com/symfony/translation/tree/v5.2.4"
}, },
"funding": [ "funding": [
{ {
@ -1469,7 +1464,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2021-01-27T10:15:41+00:00" "time": "2021-03-04T15:41:09+00:00"
}, },
{ {
"name": "symfony/translation-contracts", "name": "symfony/translation-contracts",