From 1fd78fe94a2549a3510db4b0d446023219f23536 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Wed, 19 Sep 2018 21:07:40 -0300 Subject: [PATCH] Including messages on registering and invalid product --- .../Controllers/Auth/RegisterController.php | 2 + app/Http/Controllers/ProductController.php | 12 ++-- resources/views/layouts/app.blade.php | 57 +++++++++++-------- 3 files changed, 42 insertions(+), 29 deletions(-) diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 32d4433..4247b2d 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -72,6 +72,8 @@ class RegisterController extends Controller \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; } } diff --git a/app/Http/Controllers/ProductController.php b/app/Http/Controllers/ProductController.php index 3b5e68d..39c299b 100644 --- a/app/Http/Controllers/ProductController.php +++ b/app/Http/Controllers/ProductController.php @@ -17,7 +17,7 @@ class ProductController extends Controller /** * Stores the included product into database - * + * * @return (view) The product view */ public function store(Request $request) @@ -29,7 +29,7 @@ class ProductController extends Controller /** * Delete a specified Product - * + * * @param (int) $id The product id */ public function delete(Request $request) @@ -55,14 +55,14 @@ class ProductController extends Controller $product->name = request('name'); $product->url = request('url'); $product->save(); - return redirect('product/'.request('product')); + return redirect('product/' . request('product')); } /** * Show a specified Product - * + * * @param (int) $id The product id - * + * * @return \Illuminate\Http\Response */ public function show($id) @@ -70,8 +70,8 @@ class ProductController extends Controller $product = Product::fromAuthUser()->find($id); if (!$product) { + session()->flash('danger', "The product doesn't exist or doesn't belongs to you."); return back(); - } return view('product.show', compact('product')); } diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 943ad0b..29ad403 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -1,5 +1,6 @@ + @@ -19,6 +20,7 @@ +
+ @endguest + @if ($flashMsg = session('primary')) + + @endif + @if ($flashMsg = session('danger')) + + @endif +
@yield('content')
- + + \ No newline at end of file