id)->count()<$group->groupAmount){ //Make a new keyword[Only to be used if you need to make a new of something] $keyword = new KeyWord(); //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"); } } //TODO make toast feedback }