Create user artisan command and functional login working.
This commit is contained in:
parent
0278a396e5
commit
27825b8356
|
|
@ -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.');
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1 +1 @@
|
||||||
Hello
|
Hello {{ auth()->getUser()->name }}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<x-form.checkbox name="remember" label="Remember me"/>
|
<x-form.checkbox name="remember" label="Remember me"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-3 flex justify-end">
|
<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>
|
</div>
|
||||||
</x-form>
|
</x-form>
|
||||||
</x-card>
|
</x-card>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue