Browse Source

Gantt ftth parents

pull/3/head
Wahyu Ramadhan 2 years ago
parent
commit
05e34cb66d
  1. 24
      app/Http/Controllers/HierarchyFtthController.php
  2. 1
      routes/web.php

24
app/Http/Controllers/HierarchyFtthController.php

@ -149,6 +149,30 @@ class HierarchyFtthController extends Controller
}
}
}
public function getTreeByGantt($gantt_id)
{
$finalData = [];
$gantt = VersionGantt::find($gantt_id);
if ($gantt->hierarchy_ftth_id) {
$ftth = HierarchyFtth::find($gantt->hierarchy_ftth_id);
array_push($finalData, $ftth);
if($ftth->parent_id){
$this->getParents($finalData, $ftth->parent_id);
}
} else {
return response()->json(['status'=>'success','data'=>$finalData,'code'=>200], 200);
}
return response()->json(['status'=>'success','data'=>$finalData,'code'=>200], 200);
}
public function getParents(&$data, $id){
$ftth = HierarchyFtth::find($id);
array_push($data, $ftth);
if ($ftth->parent_id) {
$this->getParents($data, $ftth->parent_id);
}
}
public function getTreeByProject($project_id)
{

1
routes/web.php

@ -448,6 +448,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->put('/hierarchy-ftths/{id}', 'HierarchyFtthController@update');
$router->delete('/hierarchy-ftths/{id}', 'HierarchyFtthController@destroy');
$router->get('/hierarchy-ftths/tree/{project_id}', 'HierarchyFtthController@getTreeByProject');
$router->get('/hierarchy-ftths/tree-gantt/{gantt_id}', 'HierarchyFtthController@getTreeByGantt');
$router->post('/map-monitoring/search', 'MapMonitoringController@search');
});

Loading…
Cancel
Save