|
|
|
@ -312,6 +312,32 @@ class ActivityController extends Controller
|
|
|
|
|
return response()->json(['status' => 'success', 'message' => 'Activity Updated!', 'code' => 200], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function batchUpdate(Request $request, $ganttId) |
|
|
|
|
{ |
|
|
|
|
$entities = $request->all(); |
|
|
|
|
if (empty($ganttId) || !is_int((int) $ganttId)) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
|
$activity = Activity::where('version_gantt_id',$ganttId)->get(); |
|
|
|
|
$link = Link::where('version_gantt_id', $ganttId)->get(); |
|
|
|
|
if (!$activity) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Activity not found!', 'code' => 404], 404); |
|
|
|
|
if (!$link) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Link not found!', 'code' => 404], 404); |
|
|
|
|
foreach ($entities as $entity) { |
|
|
|
|
if ($entity['entity'] == "task") { |
|
|
|
|
$activityToUpdate = $activity->firstWhere('id', $entity['data']['id']); |
|
|
|
|
$entity['data']['name'] = $entity['data']['text']; |
|
|
|
|
if(!$activityToUpdate->update($entity['data'])) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Failed to update activity !', 'code' => 500], 500); |
|
|
|
|
} else if ($entity['entity'] == "link"){ |
|
|
|
|
$linkToUpdate = $link->firstWhere('id', $entity['data']['id']); |
|
|
|
|
if(!$linkToUpdate->update($entity['data'])) |
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Failed to update link !', 'code' => 500], 500); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return response()->json(['status' => 'success', 'message' => 'Activity Updated!', 'code' => 200], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function delete($id) |
|
|
|
|
{ |
|
|
|
|
if (!$data = Activity::find($id)) |
|
|
|
|