alex.test/app/Console/Commands/MakeUser.php

37 lines
703 B
PHP
Raw Permalink Normal View History

2024-09-17 14:50:06 +02:00
<?php
namespace App\Console\Commands;
use App\Models\User;
use Illuminate\Console\Command;
class MakeUser extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'make:user {name}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new user';
/**
* Execute the console command.
*/
public function handle()
{
$name = (string) $this->argument('name');
$user = new User();
$user->name = $name;
$user->save();
$id = $user->id;
$this->info("Created user with id $id");
}
}