|
|
|
@ -1,22 +1,23 @@
|
|
|
|
|
<?php |
|
|
|
|
namespace App\Http\Controllers; |
|
|
|
|
|
|
|
|
|
use App\Helpers\MasterFunctionsHelper; |
|
|
|
|
use App\Models\Activity; |
|
|
|
|
use App\Models\AssignMaterial; |
|
|
|
|
use App\Models\CommentActivity; |
|
|
|
|
use DateTime; |
|
|
|
|
use App\Models\Link; |
|
|
|
|
use App\Models\User; |
|
|
|
|
use App\Models\Project; |
|
|
|
|
use App\Models\TemplateGantt; |
|
|
|
|
use App\Models\Activity; |
|
|
|
|
use App\Models\TmpImport; |
|
|
|
|
use App\Models\VersionGantt; |
|
|
|
|
use App\Models\UserToActivity; |
|
|
|
|
use App\Models\UserToProyek; |
|
|
|
|
use App\Models\User; |
|
|
|
|
use App\Models\VersionGantt; |
|
|
|
|
use Illuminate\Http\Request; |
|
|
|
|
use App\Models\TemplateGantt; |
|
|
|
|
use App\Models\AssignMaterial; |
|
|
|
|
use App\Models\UserToActivity; |
|
|
|
|
use App\Models\ActivityDokumen; |
|
|
|
|
use App\Models\CommentActivity; |
|
|
|
|
use Illuminate\Support\Facades\DB; |
|
|
|
|
use Illuminate\Support\Facades\Log; |
|
|
|
|
use DateTime; |
|
|
|
|
use App\Helpers\MasterFunctionsHelper; |
|
|
|
|
|
|
|
|
|
class ActivityController extends Controller |
|
|
|
|
{ |
|
|
|
@ -500,13 +501,26 @@ class ActivityController extends Controller
|
|
|
|
|
{ |
|
|
|
|
if (!$data = Activity::find($id)) |
|
|
|
|
return response()->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)) |
|
|
|
|