Including messages on registering and invalid product

This commit is contained in:
Bruno F. Fontes 2018-09-19 21:07:40 -03:00
parent 02f303825e
commit aebffe304f
3 changed files with 42 additions and 29 deletions

View File

@ -72,6 +72,8 @@ class RegisterController extends Controller
\Mail::to($user)->send(new Welcome($user)); \Mail::to($user)->send(new Welcome($user));
session()->flash('primary', 'Thanks for registering. Please, do not forget to validate your e-mail address.');
return $user; return $user;
} }
} }

View File

@ -70,8 +70,8 @@ class ProductController extends Controller
$product = Product::fromAuthUser()->find($id); $product = Product::fromAuthUser()->find($id);
if (!$product) { if (!$product) {
session()->flash('danger', "The product doesn't exist or doesn't belongs to you.");
return back(); return back();
} }
return view('product.show', compact('product')); return view('product.show', compact('product'));
} }

View File

@ -1,5 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}"> <html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
@ -19,6 +20,7 @@
<!-- Styles --> <!-- Styles -->
<link href="{{ asset('css/app.css') }}" rel="stylesheet"> <link href="{{ asset('css/app.css') }}" rel="stylesheet">
</head> </head>
<body> <body>
<div id="app"> <div id="app">
<nav class="navbar navbar-expand-md navbar-light navbar-laravel"> <nav class="navbar navbar-expand-md navbar-light navbar-laravel">
@ -26,7 +28,8 @@
<a class="navbar-brand" href="{{ url('/') }}"> <a class="navbar-brand" href="{{ url('/') }}">
{{ config('app.name', 'Laravel') }} {{ config('app.name', 'Laravel') }}
</a> </a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}"> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
@ -48,13 +51,13 @@
</li> </li>
@else @else
<li class="nav-item dropdown"> <li class="nav-item dropdown">
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre> <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false" v-pre>
{{ Auth::user()->name }} <span class="caret"></span> {{ Auth::user()->name }} <span class="caret"></span>
</a> </a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown"> <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{{ route('logout') }}" <a class="dropdown-item" href="{{ route('logout') }}" onclick="event.preventDefault();
onclick="event.preventDefault();
document.getElementById('logout-form').submit();"> document.getElementById('logout-form').submit();">
{{ __('Logout') }} {{ __('Logout') }}
</a> </a>
@ -70,9 +73,17 @@
</div> </div>
</nav> </nav>
@if ($flashMsg = session('primary'))
<div class="alert alert-primary text-center" role="alert">{{ $flashMsg }}</div>
@endif
@if ($flashMsg = session('danger'))
<div class="alert alert-danger text-center" role="alert">{{ $flashMsg }}</div>
@endif
<main class="py-4"> <main class="py-4">
@yield('content') @yield('content')
</main> </main>
</div> </div>
</body> </body>
</html> </html>