I am building an app using Laravel and Inertia+vue.js.
On registration, besides the Terms and Privacy Policy acceptation checkbox (which is fully handled by Jetstream), I have to implement another checkbox in order to subscribe to the newsletter. For the moment, it just has to be a boolean insertion in the DB on submit.
here is the Jetstream template :
<div v-if="$page.props.jetstream.hasTermsAndPrivacyPolicyFeature" class="mt-4">
<JetLabel for="terms">
<div class="flex items-center">
<JetCheckbox id="terms" v-model:checked="form.terms" name="terms" />
<div class="ml-2">
I agree to the <a target="_blank" :href="route('terms.show')" class="underline text-sm text-gray-600 hover:text-gray-900">Terms of Service</a> and <a target="_blank" :href="route('policy.show')" class="underline text-sm text-gray-600 hover:text-gray-900">Privacy Policy</a>
</div>
</div>
</JetLabel>
</div>
I thought the subscribe checkbox would be the same but I have absolutly no idea on how to persist the data in DB as user is not even registered at this moment.
@ruben777 On the server side, instead of persisting the preference you could just instead dispatch a queued job to subscribe the user’s email address to your mailing list:
if ($request->boolean('subscribe')) {
SubscribeToNewsletter::dispatch($request->input('email'));
}