From 6329bdf5d8ffcd68f581867120b73a64b1e76a68 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 26 Mar 2019 20:25:27 -0600 Subject: [PATCH] Add UserAdmin command --- app/Console/Commands/UserAdmin.php | 58 ++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 app/Console/Commands/UserAdmin.php diff --git a/app/Console/Commands/UserAdmin.php b/app/Console/Commands/UserAdmin.php new file mode 100644 index 000000000..efdfbdce8 --- /dev/null +++ b/app/Console/Commands/UserAdmin.php @@ -0,0 +1,58 @@ +argument('id'); + $user = User::whereUsername($id)->orWhere('id', $id)->first(); + if(!$user) { + $this->error('Could not find any user with that username or id.'); + exit; + } + $this->info('Found username: ' . $user->username); + $state = $user->is_admin ? 'Remove admin privileges from this user?' : 'Add admin privileges to this user?'; + $confirmed = $this->confirm($state); + if(!$confirmed) { + exit; + } + + $user->is_admin = !$user->is_admin; + $user->save(); + $this->info('Successfully changed permissions!'); + } +}