Initial commit of testapi
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class mkuser extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'app:mkuser';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new user interactively';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// Gather user information
|
||||
$name = $this->ask('Enter the user name');
|
||||
$email = $this->ask('Enter the user email');
|
||||
$password = $this->secret('Enter the user password');
|
||||
|
||||
// Create the user
|
||||
$user = User::create([
|
||||
'name' => $name,
|
||||
'email' => $email,
|
||||
'password' => Hash::make($password),
|
||||
'email_verified_at' => Carbon::now(),
|
||||
]);
|
||||
|
||||
// Output success message
|
||||
$this->info("User '{$user->name}' ({$user->email}) created successfully with ID {$user->id}.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user