Skip to content

Commit 21491e3

Browse files
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
1 parent 90e2d0d commit 21491e3

File tree

9 files changed

+67
-11
lines changed

9 files changed

+67
-11
lines changed

app/Http/Requests/Admin/Egg/EggFormRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function rules()
2020
{
2121
$rules = [
2222
'name' => 'required|string|max:255',
23-
'description' => 'required|string',
23+
'description' => 'nullable|string',
2424
'docker_image' => 'required|string|max:255',
2525
'startup' => 'required|string',
2626
'config_from' => 'sometimes|bail|nullable|numeric',

app/Http/Requests/Admin/Nest/StoreNestFormRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function rules()
2020
{
2121
return [
2222
'name' => 'required|string|min:1|max:255',
23-
'description' => 'required|nullable|string',
23+
'description' => 'string|nullable|',
2424
];
2525
}
2626
}

app/Models/Egg.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @property int $nest_id
99
* @property string $author
1010
* @property string $name
11-
* @property string $description
11+
* @property string|null $description
1212
* @property string $docker_image
1313
* @property string|null $config_files
1414
* @property string|null $config_startup
@@ -95,7 +95,7 @@ class Egg extends Model
9595
'nest_id' => 'required|bail|numeric|exists:nests,id',
9696
'uuid' => 'required|string|size:36',
9797
'name' => 'required|string|max:255',
98-
'description' => 'required|string',
98+
'description' => 'string|nullable',
9999
'author' => 'required|string|email',
100100
'docker_image' => 'required|string|max:255',
101101
'startup' => 'required|nullable|string',

app/Models/Location.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Location extends Model
3131
*/
3232
public static $validationRules = [
3333
'short' => 'required|string|between:1,60|unique:locations,short',
34-
'long' => 'required|string|between:1,255',
34+
'long' => 'string|nullable|between:1,255',
3535
];
3636

3737
/**

app/Models/Nest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @property string $uuid
88
* @property string $author
99
* @property string $name
10-
* @property string $description
10+
* @property string|null $description
1111
* @property \Carbon\Carbon $created_at
1212
* @property \Carbon\Carbon $updated_at
1313
*
@@ -46,7 +46,7 @@ class Nest extends Model
4646
public static $validationRules = [
4747
'author' => 'required|string|email',
4848
'name' => 'required|string|max:255',
49-
'description' => 'sometimes|nullable|string',
49+
'description' => 'nullable|string',
5050
];
5151

5252
/**

app/Models/Node.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* @property string $uuid
1414
* @property bool $public
1515
* @property string $name
16-
* @property string $description
16+
* @property string|null $description
1717
* @property int $location_id
1818
* @property string $fqdn
1919
* @property string $scheme
@@ -111,7 +111,7 @@ class Node extends Model
111111
*/
112112
public static $validationRules = [
113113
'name' => 'required|regex:/^([\w .-]{1,100})$/',
114-
'description' => 'string',
114+
'description' => 'string|nullable',
115115
'location_id' => 'required|exists:locations,id',
116116
'public' => 'boolean',
117117
'fqdn' => 'required|string',
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class AllowNullableDescriptions extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::table('eggs', function (Blueprint $table) {
17+
$table->text('description')->nullable()->change();
18+
});
19+
20+
Schema::table('nests', function (Blueprint $table) {
21+
$table->text('description')->nullable()->change();
22+
});
23+
24+
Schema::table('nodes', function (Blueprint $table) {
25+
$table->text('description')->nullable()->change();
26+
});
27+
28+
Schema::table('locations', function (Blueprint $table) {
29+
$table->text('long')->nullable()->change();
30+
});
31+
}
32+
33+
/**
34+
* Reverse the migrations.
35+
*
36+
* @return void
37+
*/
38+
public function down()
39+
{
40+
Schema::table('eggs', function (Blueprint $table) {
41+
$table->text('description')->nullable(false)->change();
42+
});
43+
44+
Schema::table('nests', function (Blueprint $table) {
45+
$table->text('description')->nullable(false)->change();
46+
});
47+
48+
Schema::table('nodes', function (Blueprint $table) {
49+
$table->text('description')->nullable(false)->change();
50+
});
51+
52+
Schema::table('locations', function (Blueprint $table) {
53+
$table->text('long')->nullable(false)->change();
54+
});
55+
}
56+
}

resources/views/admin/eggs/view.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
</div>
9090
<div class="col-sm-6">
9191
<div class="form-group">
92-
<label for="pDescription" class="control-label">Description <span class="field-required"></span></label>
92+
<label for="pDescription" class="control-label">Description</label>
9393
<textarea id="pDescription" name="description" class="form-control" rows="6">{{ $egg->description }}</textarea>
9494
<p class="text-muted small">A description of this Egg that will be displayed throughout the Panel as needed.</p>
9595
</div>

resources/views/admin/nests/view.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
</div>
3333
</div>
3434
<div class="form-group">
35-
<label class="control-label">Description <span class="field-required"></span></label>
35+
<label class="control-label">Description</label>
3636
<div>
3737
<textarea name="description" class="form-control" rows="7">{{ $nest->description }}</textarea>
3838
</div>

0 commit comments

Comments
 (0)