Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| UserCreate | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||
| handle | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Console\Commands; |
| 4 | |
| 5 | use App\Models\User; |
| 6 | use Illuminate\Console\Command; |
| 7 | use Illuminate\Support\Facades\Hash; |
| 8 | |
| 9 | /** |
| 10 | * @codeCoverageIgnore |
| 11 | */ |
| 12 | class UserCreate extends Command |
| 13 | { |
| 14 | /** |
| 15 | * The name and signature of the console command. |
| 16 | * |
| 17 | * @var string |
| 18 | */ |
| 19 | protected $signature = 'user:create'; |
| 20 | |
| 21 | /** |
| 22 | * The console command description. |
| 23 | * |
| 24 | * @var string |
| 25 | */ |
| 26 | protected $description = 'Command description'; |
| 27 | |
| 28 | /** |
| 29 | * Execute the console command. |
| 30 | * |
| 31 | * @return integer |
| 32 | */ |
| 33 | public function handle() |
| 34 | { |
| 35 | $firstname = $this->ask('What is the firstname?'); |
| 36 | $lastname = $this->ask('What is the lastname?'); |
| 37 | $email = $this->ask('What is the email?'); |
| 38 | $pwd = $this->secret('What is the password?'); |
| 39 | |
| 40 | $user = new User(); |
| 41 | $user->firstname = $firstname; |
| 42 | $user->lastname = $lastname; |
| 43 | $user->email = $email; |
| 44 | $user->password = Hash::make($pwd); |
| 45 | $user->save(); |
| 46 | |
| 47 | $this->info('User created.'); |
| 48 | return 0; |
| 49 | } |
| 50 | } |