| 1 | <?php |
||
| 10 | class UserDelete extends Command |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * The console command name. |
||
| 14 | * |
||
| 15 | * @var string |
||
| 16 | */ |
||
| 17 | protected $name = 'user:delete'; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * The console command description. |
||
| 21 | * |
||
| 22 | * @var string |
||
| 23 | */ |
||
| 24 | protected $description = 'Delete a user.'; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Execute the console command. |
||
| 28 | * |
||
| 29 | * @return mixed |
||
| 30 | */ |
||
| 31 | public function fire() |
||
| 32 | { |
||
| 33 | $email = $this->argument('email'); |
||
| 34 | |||
| 35 | try { |
||
| 36 | $user = User::whereEmail($email)->firstOrFail(); |
||
| 37 | $user->delete(); |
||
| 38 | |||
| 39 | $this->info('User deleted.'); |
||
| 40 | } catch (ModelNotFoundException $e) { |
||
| 41 | $this->error('Did not find a user with the given email address'); |
||
| 42 | } |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Get the console command arguments. |
||
| 47 | * |
||
| 48 | * @return array |
||
| 49 | */ |
||
| 50 | 4 | protected function getArguments() |
|
| 56 | } |
||
| 57 |