Advertisement
Guest User

Untitled

a guest
May 5th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Console\Commands;
  4.  
  5. use Illuminate\Console\Command;
  6. use App\User;
  7.  
  8. class AddUser extends Command
  9. {
  10. /**
  11. * The name and signature of the console command.
  12. *
  13. * @var string
  14. */
  15. protected $signature = 'user:add {email}';
  16.  
  17. /**
  18. * The console command description.
  19. *
  20. * @var string
  21. */
  22. protected $description = 'Creates a new user';
  23.  
  24. /**
  25. * Create a new command instance.
  26. *
  27. * @return void
  28. */
  29. public function __construct()
  30. {
  31. parent::__construct();
  32. }
  33.  
  34. /**
  35. * Execute the console command.
  36. *
  37. * @return mixed
  38. */
  39. public function handle()
  40. {
  41. $email = $this->argument('email');
  42.  
  43. if ($this->confirm('Let system generate password for you?')) {
  44. $password = str_random(16);
  45. $this->info("Your password: $password");
  46. } else {
  47. $password = $this->secret('Please enter your new password');
  48. }
  49.  
  50. $password = bcrypt($password);
  51. User::create(compact('email', 'password'));
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement