Page MenuHomePhorge

SetRoleCommand.php
No OneTemporary

Authored By
Unknown
Size
901 B
Referenced Files
None
Subscribers
None

SetRoleCommand.php

<?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;
}
$user->role = $role;
$user->save();
}
}

File Metadata

Mime Type
text/x-php
Expires
Fri, Apr 24, 2:21 PM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18863616
Default Alt Text
SetRoleCommand.php (901 B)

Event Timeline