Page MenuHomePhorge

D4986.1775216790.diff
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

D4986.1775216790.diff

diff --git a/src/app/Console/Commands/User/SetRoleCommand.php b/src/app/Console/Commands/User/SetRoleCommand.php
new file mode 100644
--- /dev/null
+++ b/src/app/Console/Commands/User/SetRoleCommand.php
@@ -0,0 +1,52 @@
+<?php
+
+namespace App\Console\Commands\User;
+
+use App\Console\Command;
+use App\User;
+
+class SetRoleCommand extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'user:set-role {user} {role}';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = "Set a role on the user";
+
+ /**
+ * Execute the console command.
+ *
+ * @return mixed
+ */
+ public function handle()
+ {
+ $user = $this->getUser($this->argument('user'));
+
+ if (!$user) {
+ $this->error("User not found.");
+ return 1;
+ }
+ $role = $this->argument('role');
+ if ($role === 'null') {
+ $this->info("Removing role.");
+ $role = null;
+ } else {
+ if ($role === User::ROLE_ADMIN || $role === User::ROLE_RESELLER) {
+ $this->info("Setting role {$role}.");
+ } else {
+ $this->error("Invalid role {$role}.");
+ return 1;
+ }
+ }
+ $user->role = $role;
+ $user->save();
+ }
+}

File Metadata

Mime Type
text/plain
Expires
Fri, Apr 3, 11:46 AM (9 h, 19 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18823889
Default Alt Text
D4986.1775216790.diff (1 KB)

Event Timeline