From 144659017172cca2695d5cd9e1cbc5e6d8e4a8ce Mon Sep 17 00:00:00 2001 From: Zain Fauzan Rofie Azizi Date: Tue, 26 Jun 2018 09:49:54 +0800 Subject: [PATCH] complete cancel ship order --- app/Http/Controllers/SoController.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/SoController.php b/app/Http/Controllers/SoController.php index 125c6ea..0f138c7 100644 --- a/app/Http/Controllers/SoController.php +++ b/app/Http/Controllers/SoController.php @@ -74,13 +74,17 @@ class SoController extends Controller */ public function cancelOrder(Request $request) { - $so = So::where('user_id', Auth::user()->id)->where('id', $com_id)->firstOrFail(); - + + if (!$so = So::where('com_id', Auth::user()->company())->where('id', $id)->first()) + { + return response()->json(['message'=>'Access denied'], 200); + } + + $so->is_cancel = true; $so->save(); - $com_id = auth()->user->id; - return response()->json(['so'=>$so],200); + return response()->json(['message'=>'Success'],200); } /** @@ -92,7 +96,7 @@ class SoController extends Controller */ public function update(Request $request, $id) { - $so = So::where('com_id', Auth::user()->company())->where('id', $id)->firstOrFail(); + $so = So::where('com_id', Auth::user()->company())->where('id', $id)->first(); if (!$so) { @@ -134,7 +138,6 @@ class SoController extends Controller } - /** * Remove the shipping order and item *