Commit bda474aa by Florian Shllaku

Newsletter validation

parent bb696f31
...@@ -14,6 +14,9 @@ class NewsletterController extends Controller ...@@ -14,6 +14,9 @@ class NewsletterController extends Controller
public function store(Request $request) public function store(Request $request)
{ {
$this->validate($request, [
'email' => 'required|email',
]);
if ( ! Newsletter::isSubscribed($request->email) ) if ( ! Newsletter::isSubscribed($request->email) )
{ {
Newsletter::subscribePending($request->email); Newsletter::subscribePending($request->email);
......
...@@ -49,8 +49,19 @@ ...@@ -49,8 +49,19 @@
@endif @endif
<h2 class="title">Subscribe to our newsletter!</h2> <h2 class="title">Subscribe to our newsletter!</h2>
<br> <br>
@if(count($errors) > 0)
<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button>
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<p class="paragraph">Subscribe to our Newsletter to get more information about fiat and crypto currencies. By subscribing to us, you will be receiving everyday five main news article stories to get updated on what is going on in the currency world.</p> <p class="paragraph">Subscribe to our Newsletter to get more information about fiat and crypto currencies. By subscribing to us, you will be receiving everyday five main news article stories to get updated on what is going on in the currency world.</p>
<br> <br>
<form action={{url('/subscribe')}} method="post"> <form action={{url('/subscribe')}} method="post">
@csrf @csrf
<div class="input-group"> <div class="input-group">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment