From a90e077b9b58f88b68bc7573927be27c0f3fc237 Mon Sep 17 00:00:00 2001 From: wahyuun Date: Mon, 13 Nov 2023 15:50:03 +0700 Subject: [PATCH] handle delete Gantt --- .../Controllers/VersionGanttController.php | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/VersionGanttController.php b/app/Http/Controllers/VersionGanttController.php index c3fe398..c5fabab 100644 --- a/app/Http/Controllers/VersionGanttController.php +++ b/app/Http/Controllers/VersionGanttController.php @@ -2,8 +2,15 @@ namespace App\Http\Controllers; -use Illuminate\Http\Request; +use App\Models\Link; +use App\Models\Holiday; +use App\Models\Activity; use App\Models\VersionGantt; +use Illuminate\Http\Request; +use App\Models\ShowHideColumn; +use App\Models\UserToActivity; +use App\Models\UserToVersionGantt; +use App\Models\ActivityProgressLog; class VersionGanttController extends Controller { @@ -49,6 +56,7 @@ class VersionGanttController extends Controller if($data){ $delete = $data->delete(); + $this->deleteRelative($data['id']); }else{ return response()->json(['status'=>'failed','message'=>'data version gantt Project not found!','code'=>400], 400); die(); @@ -62,6 +70,17 @@ class VersionGanttController extends Controller } } + private function deleteRelative($version_gantt_id) + { + UserToActivity::where('version_gantt_id', $version_gantt_id)->delete(); + Activity::where('version_gantt_id', $version_gantt_id)->delete(); + ShowHideColumn::where('version_gantt_id', $version_gantt_id)->delete(); + Link::where('version_gantt_id', $version_gantt_id)->delete(); + UserToVersionGantt::where('version_gantt_id', $version_gantt_id)->delete(); + Holiday::where('version_gantt_id', $version_gantt_id)->delete(); + ActivityProgressLog::where('version_gantt_id', $version_gantt_id)->delete(); + } + public function edit($id){ if(!$id || (int) $id < 0 || $id==""){ return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);