From 3de57df3d047256111481b9fe9b99a6092e3e7d7 Mon Sep 17 00:00:00 2001 From: kasper Franz Date: Sat, 26 Aug 2017 10:16:09 +0200 Subject: [PATCH 1/3] using the placeholder value if nothing is specified in rules on a new variable fixes #564 --- CHANGELOG.md | 3 +++ app/Repositories/VariableRepository.php | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b28f1325a..8399f84b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ This project follows [Semantic Versioning](http://semver.org) guidelines. * Support for CS:GO as a default service option selection. * Support for GMOD as a default service option selection. +### Fixed +* Using default value in rules when creating a new variable if the rules is empty. + ## v0.6.4 (Courageous Carniadactylus) ### Fixed * Fixed the console rendering on page load, I guess people don't like watching it load line-by-line for 10 minutes. Who would have guessed... diff --git a/app/Repositories/VariableRepository.php b/app/Repositories/VariableRepository.php index 1aded8293..9dc597e50 100644 --- a/app/Repositories/VariableRepository.php +++ b/app/Repositories/VariableRepository.php @@ -47,6 +47,11 @@ class VariableRepository { $option = ServiceOption::select('id')->findOrFail($option); + // If there is not a rules present let's populate it with the default/placeholder value. + if(!array_key_exists('rules',$data) || empty($data['rules'])){ + $data['rules'] = 'required|string|max:20'; + } + $validator = Validator::make($data, [ 'name' => 'required|string|min:1|max:255', 'description' => 'sometimes|nullable|string', From 3a921133fe67fca51231e1f49def77da099e0ec3 Mon Sep 17 00:00:00 2001 From: kasper Franz Date: Sat, 26 Aug 2017 10:17:57 +0200 Subject: [PATCH 2/3] StyleCi --- app/Repositories/VariableRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Repositories/VariableRepository.php b/app/Repositories/VariableRepository.php index 9dc597e50..e0ae408a7 100644 --- a/app/Repositories/VariableRepository.php +++ b/app/Repositories/VariableRepository.php @@ -48,7 +48,7 @@ class VariableRepository $option = ServiceOption::select('id')->findOrFail($option); // If there is not a rules present let's populate it with the default/placeholder value. - if(!array_key_exists('rules',$data) || empty($data['rules'])){ + if (! array_key_exists('rules', $data) || empty($data['rules'])) { $data['rules'] = 'required|string|max:20'; } From 3377898143a1ea6b4fe51be02188041cdc46be66 Mon Sep 17 00:00:00 2001 From: kasper Franz Date: Tue, 12 Sep 2017 10:37:53 +0200 Subject: [PATCH 3/3] set the default value as value! --- .../pterodactyl/admin/services/options/variables.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/themes/pterodactyl/admin/services/options/variables.blade.php b/resources/themes/pterodactyl/admin/services/options/variables.blade.php index 975745dfe..c3e6a1419 100644 --- a/resources/themes/pterodactyl/admin/services/options/variables.blade.php +++ b/resources/themes/pterodactyl/admin/services/options/variables.blade.php @@ -139,7 +139,7 @@
- +

These rules are defined using standard Laravel Framework validation rules.