From 1350c62f14db0a93738c6b633e5cd3830b89a41e Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Wed, 19 Sep 2018 15:11:30 -0300 Subject: [PATCH] Fixed: error message when opening other user product The user can only open their own products. If the user tried to open a product that belongs to other person, the site were returning an error message. Now it just go back to the last page. --- app/Http/Controllers/ProductController.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Http/Controllers/ProductController.php b/app/Http/Controllers/ProductController.php index ba23265..3b5e68d 100644 --- a/app/Http/Controllers/ProductController.php +++ b/app/Http/Controllers/ProductController.php @@ -62,10 +62,17 @@ class ProductController extends Controller * Show a specified Product * * @param (int) $id The product id + * + * @return \Illuminate\Http\Response */ public function show($id) { $product = Product::fromAuthUser()->find($id); + + if (!$product) { + return back(); + + } return view('product.show', compact('product')); } }