From dcede1f72a7f57f62a662ab7eb2443db9f495d2a Mon Sep 17 00:00:00 2001 From: wahyuun Date: Tue, 5 Sep 2023 17:01:28 +0700 Subject: [PATCH] query ProjectController@edit --- app/Http/Controllers/ProjectController.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 5e0fbde..a6fac6a 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -65,11 +65,16 @@ class ProjectController extends Controller return response()->json(['status'=>'success','message'=>'Data added!', 'data_result' =>$dataResultInsert, 'code'=> 200], 200); } - public function edit($id){ - if(empty($id) || !is_int((int)$id)) - return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); + public function edit($id) + { + if (empty($id) || !is_int((int)$id)) + return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); + + $result = Project::query() + ->select(array_diff(DB::getSchemaBuilder()->getColumnListing('m_proyek'), ['created_by', 'created_at', 'updated_at', 'updated_by', 'scurve'])) + ->whereId($id) + ->first(); - $result = Project::find($id); if(!$result) return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404);