87 lines
4.6 KiB
PHP
87 lines
4.6 KiB
PHP
<?php
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Auth\Events\Registered;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Validation\Rules;
|
|
use Livewire\Attributes\Layout;
|
|
use Livewire\Volt\Component;
|
|
|
|
new #[Layout('layouts.guest')] class extends Component
|
|
{
|
|
public string $name = '';
|
|
public string $email = '';
|
|
public string $password = '';
|
|
public string $password_confirmation = '';
|
|
|
|
public function register(): void
|
|
{
|
|
$validated = $this->validate([
|
|
'name' => ['required', 'string', 'max:255'],
|
|
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:'.User::class],
|
|
'password' => ['required', 'string', 'confirmed', Rules\Password::defaults()],
|
|
]);
|
|
|
|
$validated['password'] = Hash::make($validated['password']);
|
|
|
|
event(new Registered($user = User::create($validated)));
|
|
|
|
Auth::login($user);
|
|
|
|
$this->redirect(route('dashboard', absolute: false), navigate: true);
|
|
}
|
|
}; ?>
|
|
|
|
<div>
|
|
<h2 style="font-size:1.25rem;font-weight:600;color:#f0f0f5;margin-bottom:1.5rem;">Create account</h2>
|
|
|
|
<form wire:submit="register">
|
|
<div>
|
|
<label for="name" style="display:block;font-size:0.875rem;color:#8888a0;margin-bottom:0.375rem;">Name</label>
|
|
<input wire:model="name" id="name" type="text" name="name" required autofocus autocomplete="name"
|
|
style="width:100%;padding:0.5rem 0.75rem;background-color:#111117;border:1px solid rgba(255,255,255,0.06);border-radius:0.5rem;color:#f0f0f5;outline:none;"
|
|
onfocus="this.style.borderColor='#4f8ef7'" onblur="this.style.borderColor='rgba(255,255,255,0.06)'" />
|
|
<x-input-error :messages="$errors->get('name')" class="mt-2" />
|
|
</div>
|
|
|
|
<div style="margin-top:1rem;">
|
|
<label for="email" style="display:block;font-size:0.875rem;color:#8888a0;margin-bottom:0.375rem;">Email</label>
|
|
<input wire:model="email" id="email" type="email" name="email" required autocomplete="username"
|
|
style="width:100%;padding:0.5rem 0.75rem;background-color:#111117;border:1px solid rgba(255,255,255,0.06);border-radius:0.5rem;color:#f0f0f5;outline:none;"
|
|
onfocus="this.style.borderColor='#4f8ef7'" onblur="this.style.borderColor='rgba(255,255,255,0.06)'" />
|
|
<x-input-error :messages="$errors->get('email')" class="mt-2" />
|
|
</div>
|
|
|
|
<div style="margin-top:1rem;">
|
|
<label for="password" style="display:block;font-size:0.875rem;color:#8888a0;margin-bottom:0.375rem;">Password</label>
|
|
<input wire:model="password" id="password" type="password" name="password" required autocomplete="new-password"
|
|
style="width:100%;padding:0.5rem 0.75rem;background-color:#111117;border:1px solid rgba(255,255,255,0.06);border-radius:0.5rem;color:#f0f0f5;outline:none;"
|
|
onfocus="this.style.borderColor='#4f8ef7'" onblur="this.style.borderColor='rgba(255,255,255,0.06)'" />
|
|
<x-input-error :messages="$errors->get('password')" class="mt-2" />
|
|
</div>
|
|
|
|
<div style="margin-top:1rem;">
|
|
<label for="password_confirmation" style="display:block;font-size:0.875rem;color:#8888a0;margin-bottom:0.375rem;">Confirm Password</label>
|
|
<input wire:model="password_confirmation" id="password_confirmation" type="password" name="password_confirmation" required autocomplete="new-password"
|
|
style="width:100%;padding:0.5rem 0.75rem;background-color:#111117;border:1px solid rgba(255,255,255,0.06);border-radius:0.5rem;color:#f0f0f5;outline:none;"
|
|
onfocus="this.style.borderColor='#4f8ef7'" onblur="this.style.borderColor='rgba(255,255,255,0.06)'" />
|
|
<x-input-error :messages="$errors->get('password_confirmation')" class="mt-2" />
|
|
</div>
|
|
|
|
<div style="display:flex;align-items:center;justify-content:space-between;margin-top:1.5rem;">
|
|
<a href="{{ route('login') }}" wire:navigate
|
|
style="font-size:0.875rem;color:#4f8ef7;text-decoration:none;"
|
|
onmouseover="this.style.opacity='.8'" onmouseout="this.style.opacity='1'">
|
|
Already have an account?
|
|
</a>
|
|
|
|
<button type="submit"
|
|
style="padding:0.5rem 1.5rem;background-color:#4f8ef7;color:#fff;border:none;border-radius:0.5rem;font-weight:500;cursor:pointer;"
|
|
onmouseover="this.style.opacity='.9'" onmouseout="this.style.opacity='1'">
|
|
Register
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|