1 | <?php |
||
2 | |||
3 | namespace Irfa\Lockout\Console\Commands; |
||
4 | |||
5 | use Illuminate\Console\Command; |
||
6 | use Irfa\Lockout\Func\Core; |
||
7 | use Symfony\Component\Console\Helper\Table; |
||
8 | |||
9 | class UnlockCommands extends Command |
||
10 | { |
||
11 | /** |
||
12 | * The name and signature of the console command. |
||
13 | * |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $signature = 'lockout:unlock {username}'; |
||
17 | |||
18 | /** |
||
19 | * The console command description. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $description = 'Unlock Account'; |
||
24 | |||
25 | /** |
||
26 | * Create a new command instance. |
||
27 | * |
||
28 | * @return void |
||
29 | */ |
||
30 | public function __construct() |
||
31 | { |
||
32 | parent::__construct(); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Execute the console command. |
||
37 | * |
||
38 | * @return mixed |
||
39 | */ |
||
40 | public function handle(Core $core) |
||
41 | { |
||
42 | $ret = $core->unlock_account($this->argument('username')); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
43 | $table = new Table($this->output); |
||
44 | $read_enc = json_decode( $ret); |
||
45 | if(!empty($read_enc)){ |
||
46 | $time = $read_enc->last_attemps; |
||
47 | $attemps = $read_enc->attemps; |
||
48 | $ip = $read_enc->ip; |
||
49 | $table->setRows([ |
||
50 | ['<fg=cyan>Login attemps', $attemps], |
||
51 | ['<fg=cyan>Last login attemps',$time], |
||
52 | ['<fg=cyan>Last IP Address',empty(end($ip))? "unknown":end($ip)], |
||
53 | ['<fg=cyan>Unlocked at',date('Y-m-d H:i:s', time())], |
||
54 | ]); |
||
55 | $table->render(); |
||
56 | } |
||
57 | // $this->line('<fg=yellow>Valid input is lock, unlock, and attemps.'); |
||
58 | |||
59 | } |
||
60 | |||
61 | } |