From 30fd9166460620e1c7de5c8ce518e1a3f3365014 Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 19 Oct 2021 22:21:32 +1100 Subject: [PATCH] Add user alias --- app/Http/Controllers/UserController.php | 3 +- .../2021_10_19_105854_add_alias_to_user.php | 32 +++++++++++++++++ resources/views/user/addedit.blade.php | 35 +++++++++++++------ 3 files changed, 58 insertions(+), 12 deletions(-) create mode 100644 database/migrations/2021_10_19_105854_add_alias_to_user.php diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 524be45..aa1530c 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -30,11 +30,12 @@ class UserController extends Controller 'min:64', //function ($attribute,$value,$fail) { return $fail('Not this time'); } ], + 'alias' => 'nullable|min:1', 'active' => 'required|boolean', 'admin' => 'required|boolean', ]); - foreach (['name','email','pgp_pubkey','active','admin'] as $key) + foreach (['name','email','pgp_pubkey','active','admin','alias'] as $key) $o->{$key} = $request->post($key); if (! $o->exists) diff --git a/database/migrations/2021_10_19_105854_add_alias_to_user.php b/database/migrations/2021_10_19_105854_add_alias_to_user.php new file mode 100644 index 0000000..026e056 --- /dev/null +++ b/database/migrations/2021_10_19_105854_add_alias_to_user.php @@ -0,0 +1,32 @@ +string('alias')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('alias'); + }); + } +} diff --git a/resources/views/user/addedit.blade.php b/resources/views/user/addedit.blade.php index 0b5ac83..a3f2769 100644 --- a/resources/views/user/addedit.blade.php +++ b/resources/views/user/addedit.blade.php @@ -29,16 +29,16 @@ -
- -
-
- active))checked @endif> - - - active))checked @endif> - -
+
+ +
+ + + + @error('alias') + {{ $message }} + @enderror +
@@ -59,7 +59,20 @@
-
+
+ +
+
+ active))checked @endif> + + + active))checked @endif> + +
+
+
+ +
id == $o->id)data-bs-toggle="tooltip" title="You cannot demote yourself" @endif>