| Conditions | 3 |
| Paths | 5 |
| Total Lines | 21 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 40 | public function handle() |
||
| 41 | { |
||
| 42 | $uid=(int)$this->option('uid'); |
||
| 43 | $reason=$this->option('reason'); |
||
| 44 | $time=$this->option('time'); |
||
| 45 | $user = User::find($uid); |
||
| 46 | if(empty($user)) { |
||
| 47 | $this->line("\n <bg=red;fg=white> Exception </> : <fg=yellow>User Not Found</>\n"); |
||
| 48 | return; |
||
| 49 | } |
||
| 50 | try{ |
||
| 51 | $ban_time = date('Y-m-d H:i:s',strtotime($time)); |
||
| 52 | UserBanned::create([ |
||
| 53 | 'user_id' => $user->id, |
||
| 54 | 'reason' => $reason, |
||
| 55 | 'removed_at' => $ban_time |
||
| 56 | ]); |
||
| 57 | $this->line("The user <fg=yellow>{$user->name}</> will be banned until <fg=yellow>{$ban_time}</>"); |
||
| 58 | }catch(Throwable $e){ |
||
|
|
|||
| 59 | $this->line("\n <bg=red;fg=white> Exception </> : <fg=yellow>Wrong Time.</>\n"); |
||
| 60 | return; |
||
| 61 | } |
||
| 64 |