diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index 733ee1d..21dc80c 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -1,22 +1,23 @@ json(['status' => 'failed', 'action' => 'error', 'message' => 'Data not found!', 'code' => 404], 404); - + $this->deleteRelative($id); if (!$data->delete()) return response()->json(['status' => 'failed', 'action' => 'error', 'message' => 'data activity failed deleted!', 'code' => 500], 500); return response()->json(['status' => 'success', "action" => "deleted", 'message' => 'data activity successfully deleted!', 'code' => 200], 200); } + private function deleteRelative($activity_id) + { + UserToActivity::where('activity_id', $activity_id)->delete(); + AssignMaterial::where('activity_id', $activity_id)->delete(); + $dataAd = ActivityDokumen::where("activity_id", $activity_id)->get(); + foreach ($dataAd as $ad) { + if(file_exists($this->pathActivityDocument.$ad->file)){ + unlink($this->pathActivityDocument.$ad->file); + } + } + ActivityDokumen::where("activity_id", $activity_id)->delete(); + } + public function getUpdate($id) { if (!$data = Activity::find($id)) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 42bcb6d..ca92810 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -9,13 +9,17 @@ use App\Models\Image; use App\Models\Holiday; use App\Models\Project; use App\Models\Activity; +use App\Models\ReportK3; use App\Jobs\ProcessSCurve; +use App\Models\AssignTools; use App\Models\OfficeHours; use App\Models\ProjectType; use App\Models\ProjectPhase; +use App\Models\ProjectRisks; use App\Models\UserToProyek; use App\Models\VersionGantt; use Illuminate\Http\Request; +use App\Models\HierarchyFtth; use App\Models\ProjectIssues; use App\Models\AssignMaterial; use App\Models\DokumenProject; @@ -26,13 +30,14 @@ use App\Models\UserToActivity; use App\Models\ActivityDokumen; use App\Models\CommentActivity; use App\Models\ProjectApproval; +use App\Models\RequestMaterial; use App\Models\ProjectMileStone; use App\Models\ProjectChecklists; use Illuminate\Support\Facades\DB; use App\Models\ProjectParticipants; use App\Models\FolderDocumentProyek; +use App\Models\ProjectToChecklistK3; use App\Helpers\MasterFunctionsHelper; -use App\Models\ProjectRisks; use App\Models\ReportActivityMaterial; use Illuminate\Support\Facades\Artisan; @@ -163,6 +168,12 @@ class ProjectController extends Controller ProjectChecklists::where('proyek_id', $project_id)->delete(); ProjectIssues::where('proyek_id', $project_id)->delete(); ProjectRisks::where('proyek_id', $project_id)->delete(); + ProjectToChecklistK3::where('proyek_id', $project_id)->delete(); + HierarchyFtth::where('project_id', $project_id)->delete(); + AssignTools::where('proyek_id', $project_id)->delete(); + OfficeHours::where('proyek_id', $project_id)->delete(); + ReportK3::where('proyek_id', $project_id)->delete(); + RequestMaterial::where('proyek_id', $project_id)->delete(); $this->deleteVersionGantt($project_id); $this->deleteDokumenProject($project_id); } 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);