Create user artisan command and functional login working.

This commit is contained in:
Matt Young 2025-12-13 21:55:08 -06:00
parent 0278a396e5
commit 27825b8356
3 changed files with 60 additions and 2 deletions

View File

@ -0,0 +1,58 @@
<?php
namespace App\Console\Commands;
use App\Actions\Fortify\CreateNewUser;
use Illuminate\Console\Command;
use function Laravel\Prompts\password;
use function Laravel\Prompts\text;
class CreateUser extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:create-user';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Creates a user';
/**
* Execute the console command.
*/
public function handle(CreateNewUser $creator)
{
$name = text(
label: 'What is the new user\'s name?',
validate: ['name' => 'required|min:3'],
);
$email = text(
label: 'What is the new user\'s email?',
validate: ['email' => 'required|email|unique:users,email'],
);
$password = password(
label: 'Desired password: ',
validate: ['password' => 'required|min:8'],
);
$password_confirmation = password(
label: 'Confirm password: ',
validate: ['password_confirmation' => 'required'],
);
$newUser = $creator->create([
'name' => $name,
'email' => $email,
'password' => $password,
'password_confirmation' => $password_confirmation,
]);
$this->info('User created successfully.');
}
}

View File

@ -1 +1 @@
Hello
Hello {{ auth()->getUser()->name }}

View File

@ -9,7 +9,7 @@
<x-form.checkbox name="remember" label="Remember me"/>
</div>
<div class="mt-3 flex justify-end">
<x-form.button size="4">Login</x-form.button>
<x-form.button size="4" type="submit">Login</x-form.button>
</div>
</x-form>
</x-card>