diff --git a/Backend/keyWordsRemaining.php b/Backend/keyWordsRemaining.php index e6be58c..da2ae6a 100644 --- a/Backend/keyWordsRemaining.php +++ b/Backend/keyWordsRemaining.php @@ -4,15 +4,33 @@ use Backend\Models\Group; use Backend\Models\KeyWord; + if(isset($_POST['submitKeyWord'])){ - $keyword = new KeyWord(); + //Find the group id + $group = Group::find($_POST['group_id']); - $keyword->keyWord = $_POST['key_word']; + //if statement to find out if the group have use all their keyWords + if(KeyWord::where('group_id', $group->id)->count()<$group->groupAmount){ - $keyword->group()->associate(Group::find($_POST['group_id'])); + //Make a new keyword[Only to be used if you need to make a new of something] + $keyword = new KeyWord(); - if(!$keyword->save()){ - return; + //Take the keyWord the user typed and set it equal to the keyword valuable + $keyword->keyWord = $_POST['key_word']; + + //Make foreign key from the groups table to the keyWords table + $keyword->group()->associate($group); + + //Try to save it + if(!$keyword->save()){ + header("location: ../Frontend/index.php?created=failed"); + }else{ + header("location: ../Frontend/index.php?created=success"); + } } -} \ No newline at end of file + //TODO make toast feedback +} + + + diff --git a/composer.lock b/composer.lock index ba26dfd..da1aef9 100644 --- a/composer.lock +++ b/composer.lock @@ -103,7 +103,7 @@ }, { "name": "illuminate/collections", - "version": "v8.30.0", + "version": "v8.31.0", "source": { "type": "git", "url": "https://github.com/illuminate/collections.git", @@ -157,7 +157,7 @@ }, { "name": "illuminate/container", - "version": "v8.30.0", + "version": "v8.31.0", "source": { "type": "git", "url": "https://github.com/illuminate/container.git", @@ -208,7 +208,7 @@ }, { "name": "illuminate/contracts", - "version": "v8.30.0", + "version": "v8.31.0", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", @@ -256,16 +256,16 @@ }, { "name": "illuminate/database", - "version": "v8.30.0", + "version": "v8.31.0", "source": { "type": "git", "url": "https://github.com/illuminate/database.git", - "reference": "a2be80ba829258b9b44fa43443aa81653604b931" + "reference": "87dd6cee1eb159dfcba95bd1d2ed59d3f3244b36" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/database/zipball/a2be80ba829258b9b44fa43443aa81653604b931", - "reference": "a2be80ba829258b9b44fa43443aa81653604b931", + "url": "https://api.github.com/repos/illuminate/database/zipball/87dd6cee1eb159dfcba95bd1d2ed59d3f3244b36", + "reference": "87dd6cee1eb159dfcba95bd1d2ed59d3f3244b36", "shasum": "" }, "require": { @@ -320,11 +320,11 @@ "issues": "https://github.com/laravel/framework/issues", "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", - "version": "v8.30.0", + "version": "v8.31.0", "source": { "type": "git", "url": "https://github.com/illuminate/macroable.git", @@ -370,16 +370,16 @@ }, { "name": "illuminate/support", - "version": "v8.30.0", + "version": "v8.31.0", "source": { "type": "git", "url": "https://github.com/illuminate/support.git", - "reference": "0f59c467c1b612122488a262e7f9fb32b30df36a" + "reference": "978e64ffb68189b70fea77e4d401f43e88fa54ca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/support/zipball/0f59c467c1b612122488a262e7f9fb32b30df36a", - "reference": "0f59c467c1b612122488a262e7f9fb32b30df36a", + "url": "https://api.github.com/repos/illuminate/support/zipball/978e64ffb68189b70fea77e4d401f43e88fa54ca", + "reference": "978e64ffb68189b70fea77e4d401f43e88fa54ca", "shasum": "" }, "require": { @@ -434,7 +434,7 @@ "issues": "https://github.com/laravel/framework/issues", "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", @@ -531,27 +531,22 @@ }, { "name": "psr/container", - "version": "1.0.0", + "version": "1.1.1", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf", + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=7.2.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, "autoload": { "psr-4": { "Psr\\Container\\": "src/" @@ -564,7 +559,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common Container Interface (PHP FIG PSR-11)", @@ -578,9 +573,9 @@ ], "support": { "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", @@ -635,16 +630,16 @@ }, { "name": "symfony/console", - "version": "v5.2.3", + "version": "v5.2.4", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "89d4b176d12a2946a1ae4e34906a025b7b6b135a" + "reference": "d6d0cc30d8c0fda4e7b213c20509b0159a8f4556" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/89d4b176d12a2946a1ae4e34906a025b7b6b135a", - "reference": "89d4b176d12a2946a1ae4e34906a025b7b6b135a", + "url": "https://api.github.com/repos/symfony/console/zipball/d6d0cc30d8c0fda4e7b213c20509b0159a8f4556", + "reference": "d6d0cc30d8c0fda4e7b213c20509b0159a8f4556", "shasum": "" }, "require": { @@ -712,7 +707,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.2.3" + "source": "https://github.com/symfony/console/tree/v5.2.4" }, "funding": [ { @@ -728,7 +723,7 @@ "type": "tidelift" } ], - "time": "2021-01-28T22:06:19+00:00" + "time": "2021-02-23T10:08:49+00:00" }, { "name": "symfony/polyfill-ctype", @@ -1297,16 +1292,16 @@ }, { "name": "symfony/string", - "version": "v5.2.3", + "version": "v5.2.4", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "c95468897f408dd0aca2ff582074423dd0455122" + "reference": "4e78d7d47061fa183639927ec40d607973699609" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/c95468897f408dd0aca2ff582074423dd0455122", - "reference": "c95468897f408dd0aca2ff582074423dd0455122", + "url": "https://api.github.com/repos/symfony/string/zipball/4e78d7d47061fa183639927ec40d607973699609", + "reference": "4e78d7d47061fa183639927ec40d607973699609", "shasum": "" }, "require": { @@ -1360,7 +1355,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.2.3" + "source": "https://github.com/symfony/string/tree/v5.2.4" }, "funding": [ { @@ -1376,20 +1371,20 @@ "type": "tidelift" } ], - "time": "2021-01-25T15:14:59+00:00" + "time": "2021-02-16T10:20:28+00:00" }, { "name": "symfony/translation", - "version": "v5.2.3", + "version": "v5.2.4", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "c021864d4354ee55160ddcfd31dc477a1bc77949" + "reference": "74b0353ab34ff4cca827a2cf909e325d96815e60" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/c021864d4354ee55160ddcfd31dc477a1bc77949", - "reference": "c021864d4354ee55160ddcfd31dc477a1bc77949", + "url": "https://api.github.com/repos/symfony/translation/zipball/74b0353ab34ff4cca827a2cf909e325d96815e60", + "reference": "74b0353ab34ff4cca827a2cf909e325d96815e60", "shasum": "" }, "require": { @@ -1406,7 +1401,7 @@ "symfony/yaml": "<4.4" }, "provide": { - "symfony/translation-implementation": "2.0" + "symfony/translation-implementation": "2.3" }, "require-dev": { "psr/log": "~1.0", @@ -1453,7 +1448,7 @@ "description": "Provides tools to internationalize your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/translation/tree/v5.2.3" + "source": "https://github.com/symfony/translation/tree/v5.2.4" }, "funding": [ { @@ -1469,7 +1464,7 @@ "type": "tidelift" } ], - "time": "2021-01-27T10:15:41+00:00" + "time": "2021-03-04T15:41:09+00:00" }, { "name": "symfony/translation-contracts",