Using Livewire's new Volt API
<?php
use function Livewire\Volt\{form, layout};
layout('layouts.public');
form(RegistrationForm::class);
$register = function () {
$this->validate();
$id = $this->form->submit();
$registration = Registration::where('unique_id', $id)->firstOrFail();
Session::flash('status', 'Your registration has been submitted successfully!');
Notification::route('mail', $registration->email)
->notify(new RegistrationConfirmed($registration));
RegistrationOccurred::dispatch($registration);
if ($registration->member_type === 'counselor') {
return $this->redirectRoute('checkout.success', ['registration' => $id]);
}
$routeName = ($registration->is_deposit)
? 'checkout.deposit'
: 'checkout';
return $this->redirectRoute($routeName, ['registration' => $id]);
};
?>
<form wire:submit="register">
</form>
Enough said.