From 21491e3aaaeb348060b32ff7c3b1b5ea4c166065 Mon Sep 17 00:00:00 2001 From: AreYouScared Date: Fri, 17 Apr 2020 20:52:40 -0400 Subject: [PATCH] Allow descrition field to be optional Allows for Nest, Node, Location and Egg description fields to be blank / nullable. Removed "required" wording next to them aswell --- .../Requests/Admin/Egg/EggFormRequest.php | 2 +- .../Admin/Nest/StoreNestFormRequest.php | 2 +- app/Models/Egg.php | 4 +- app/Models/Location.php | 2 +- app/Models/Nest.php | 4 +- app/Models/Node.php | 4 +- ..._17_203438_allow_nullable_descriptions.php | 56 +++++++++++++++++++ resources/views/admin/eggs/view.blade.php | 2 +- resources/views/admin/nests/view.blade.php | 2 +- 9 files changed, 67 insertions(+), 11 deletions(-) create mode 100644 database/migrations/2020_04_17_203438_allow_nullable_descriptions.php diff --git a/app/Http/Requests/Admin/Egg/EggFormRequest.php b/app/Http/Requests/Admin/Egg/EggFormRequest.php index 539ee3ad..6fe577ca 100644 --- a/app/Http/Requests/Admin/Egg/EggFormRequest.php +++ b/app/Http/Requests/Admin/Egg/EggFormRequest.php @@ -20,7 +20,7 @@ class EggFormRequest extends AdminFormRequest { $rules = [ 'name' => 'required|string|max:255', - 'description' => 'required|string', + 'description' => 'nullable|string', 'docker_image' => 'required|string|max:255', 'startup' => 'required|string', 'config_from' => 'sometimes|bail|nullable|numeric', diff --git a/app/Http/Requests/Admin/Nest/StoreNestFormRequest.php b/app/Http/Requests/Admin/Nest/StoreNestFormRequest.php index 56255e55..5b763be6 100644 --- a/app/Http/Requests/Admin/Nest/StoreNestFormRequest.php +++ b/app/Http/Requests/Admin/Nest/StoreNestFormRequest.php @@ -20,7 +20,7 @@ class StoreNestFormRequest extends AdminFormRequest { return [ 'name' => 'required|string|min:1|max:255', - 'description' => 'required|nullable|string', + 'description' => 'string|nullable|', ]; } } diff --git a/app/Models/Egg.php b/app/Models/Egg.php index 1bdb48ca..2c53c853 100644 --- a/app/Models/Egg.php +++ b/app/Models/Egg.php @@ -8,7 +8,7 @@ namespace Pterodactyl\Models; * @property int $nest_id * @property string $author * @property string $name - * @property string $description + * @property string|null $description * @property string $docker_image * @property string|null $config_files * @property string|null $config_startup @@ -95,7 +95,7 @@ class Egg extends Model 'nest_id' => 'required|bail|numeric|exists:nests,id', 'uuid' => 'required|string|size:36', 'name' => 'required|string|max:255', - 'description' => 'required|string', + 'description' => 'string|nullable', 'author' => 'required|string|email', 'docker_image' => 'required|string|max:255', 'startup' => 'required|nullable|string', diff --git a/app/Models/Location.php b/app/Models/Location.php index e0871edf..71d3b411 100644 --- a/app/Models/Location.php +++ b/app/Models/Location.php @@ -31,7 +31,7 @@ class Location extends Model */ public static $validationRules = [ 'short' => 'required|string|between:1,60|unique:locations,short', - 'long' => 'required|string|between:1,255', + 'long' => 'string|nullable|between:1,255', ]; /** diff --git a/app/Models/Nest.php b/app/Models/Nest.php index d2839919..8cce56f3 100644 --- a/app/Models/Nest.php +++ b/app/Models/Nest.php @@ -7,7 +7,7 @@ namespace Pterodactyl\Models; * @property string $uuid * @property string $author * @property string $name - * @property string $description + * @property string|null $description * @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $updated_at * @@ -46,7 +46,7 @@ class Nest extends Model public static $validationRules = [ 'author' => 'required|string|email', 'name' => 'required|string|max:255', - 'description' => 'sometimes|nullable|string', + 'description' => 'nullable|string', ]; /** diff --git a/app/Models/Node.php b/app/Models/Node.php index 7faccc37..5d6e3b91 100644 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -13,7 +13,7 @@ use Illuminate\Contracts\Encryption\Encrypter; * @property string $uuid * @property bool $public * @property string $name - * @property string $description + * @property string|null $description * @property int $location_id * @property string $fqdn * @property string $scheme @@ -111,7 +111,7 @@ class Node extends Model */ public static $validationRules = [ 'name' => 'required|regex:/^([\w .-]{1,100})$/', - 'description' => 'string', + 'description' => 'string|nullable', 'location_id' => 'required|exists:locations,id', 'public' => 'boolean', 'fqdn' => 'required|string', diff --git a/database/migrations/2020_04_17_203438_allow_nullable_descriptions.php b/database/migrations/2020_04_17_203438_allow_nullable_descriptions.php new file mode 100644 index 00000000..c1787a9b --- /dev/null +++ b/database/migrations/2020_04_17_203438_allow_nullable_descriptions.php @@ -0,0 +1,56 @@ +text('description')->nullable()->change(); + }); + + Schema::table('nests', function (Blueprint $table) { + $table->text('description')->nullable()->change(); + }); + + Schema::table('nodes', function (Blueprint $table) { + $table->text('description')->nullable()->change(); + }); + + Schema::table('locations', function (Blueprint $table) { + $table->text('long')->nullable()->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('eggs', function (Blueprint $table) { + $table->text('description')->nullable(false)->change(); + }); + + Schema::table('nests', function (Blueprint $table) { + $table->text('description')->nullable(false)->change(); + }); + + Schema::table('nodes', function (Blueprint $table) { + $table->text('description')->nullable(false)->change(); + }); + + Schema::table('locations', function (Blueprint $table) { + $table->text('long')->nullable(false)->change(); + }); + } +} diff --git a/resources/views/admin/eggs/view.blade.php b/resources/views/admin/eggs/view.blade.php index 527d0f30..bf2414fb 100644 --- a/resources/views/admin/eggs/view.blade.php +++ b/resources/views/admin/eggs/view.blade.php @@ -89,7 +89,7 @@
- +

A description of this Egg that will be displayed throughout the Panel as needed.

diff --git a/resources/views/admin/nests/view.blade.php b/resources/views/admin/nests/view.blade.php index d54155e5..4dff5250 100644 --- a/resources/views/admin/nests/view.blade.php +++ b/resources/views/admin/nests/view.blade.php @@ -32,7 +32,7 @@
- +