51 lines
960 B
PHP
51 lines
960 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\User;
|
|
use Illuminate\Console\Command;
|
|
|
|
class ResetRoleAsal extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'reset:roleasal';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Reset Role';
|
|
|
|
/**
|
|
* Create a new command instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function handle()
|
|
{
|
|
$all_user = User::all();
|
|
foreach($all_user as $index=>$user_kaunter){
|
|
$user = User::find($user_kaunter->id);
|
|
if($user->cawangan != 'operasi'){
|
|
$user->roles = $user->role_asal;
|
|
$user->save();
|
|
}
|
|
}
|
|
}
|
|
}
|