Redirect to login and display alert after successful registration
MODIFY
app/Http/Controllers/LoginController.php
app/Http/Controllers/LoginController.php
@@ -22,7 +22,8 @@ class LoginController extends Controller {
return redirect()
->route('login')
->with([
- 'status' => 'Failed to login'
+ 'alert_type' => 'danger',
+ 'alert_message' => 'Failed to login'
]);
}
}

MODIFY
app/Http/Controllers/RegisterController.php
app/Http/Controllers/RegisterController.php
@@ -38,6 +38,11 @@ class RegisterController extends Controller {
Mail::to($user->email)->queue(new ConfirmRegistration($user));
- return redirect('/register');
+ return redirect()
+ ->route('login')
+ ->with([
+ 'alert_type' => 'success',
+ 'alert_message' => 'You\'ve succesfully registered'
+ ]);
}
}

MODIFY
resources/views/login.blade.php
resources/views/login.blade.php
@section('body')
<div class="wrapper wrapper--narrow my-4">
<h2 class="text-center mb-4">Log in</h2>
- @if (session('status'))
- @include('partials.status_bar', ['payload' => ['classes' => 'mb-2', 'status' => session('status')]])
+ @if (session('alert_type') && session('alert_message'))
+ @include('partials.alerts.' . session('alert_type'), ['payload' => ['classes' => 'mb-2', 'message' => session('alert_message')]])
@endif
<div class="box">
<div class="box__section">

RENAME
resources/views/partials/status_bar.blade.php
resources/views/partials/alerts/danger.blade.php
<div class="row {{ $payload['classes'] }}" style="
padding: 15px;
color: #FFF;
- background: #FE7C4D;
+ background: #F86380;
border-radius: 5px;
">
<div class="row__column row__column--compact">
- <i class="fas fa-exclamation-circle"></i>
+ <i class="fas fa-times"></i>
</div>
- <div class="row__column text-center" style="font-weight: 600;">{{ $payload['status'] }}</div>
+ <div class="row__column text-center" style="font-weight: 600;">{{ $payload['message'] }}</div>
</div>

ADD
resources/views/partials/alerts/success.blade.php
+<div class="row {{ $payload['classes'] }}" style="
+ padding: 15px;
+ color: #FFF;
+ background: #AAD26F;
+ border-radius: 5px;
+">
+ <div class="row__column row__column--compact">
+ <i class="fas fa-check"></i>
+ </div>
+ <div class="row__column text-center" style="font-weight: 600;">{{ $payload['message'] }}</div>
+</div>

Redirect to login and display alert after successful registration