|
|
|
@ -49,8 +49,9 @@ class HierarchyFtthController extends Controller
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function show(HierarchyFtth $hierarchyFtth) |
|
|
|
|
public function show($id) |
|
|
|
|
{ |
|
|
|
|
$hierarchyFtth = HierarchyFtth::where('id', $id)->first(); |
|
|
|
|
try { |
|
|
|
|
return response()->json($hierarchyFtth); |
|
|
|
|
} catch (\Exception $e) { |
|
|
|
@ -61,8 +62,9 @@ class HierarchyFtthController extends Controller
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function update(Request $request, HierarchyFtth $hierarchyFtth) |
|
|
|
|
public function update(Request $request, $id) |
|
|
|
|
{ |
|
|
|
|
$hierarchyFtth = HierarchyFtth::where('id', $id)->first(); |
|
|
|
|
try { |
|
|
|
|
$hierarchyFtth->update($request->all()); |
|
|
|
|
|
|
|
|
@ -78,8 +80,9 @@ class HierarchyFtthController extends Controller
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function destroy(HierarchyFtth $hierarchyFtth) |
|
|
|
|
public function destroy($id) |
|
|
|
|
{ |
|
|
|
|
$hierarchyFtth = HierarchyFtth::where('id', $id)->first(); |
|
|
|
|
try { |
|
|
|
|
$hierarchyFtth->delete(); |
|
|
|
|
|
|
|
|
@ -94,4 +97,29 @@ class HierarchyFtthController extends Controller
|
|
|
|
|
], 500); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getTreeByProject($project_id) |
|
|
|
|
{ |
|
|
|
|
$data = HierarchyFtth::where('project_id', $project_id)->whereNull('parent_id')->orderByRaw('id ASC')->get(); |
|
|
|
|
$finalData = []; |
|
|
|
|
foreach($data as $objRow){ |
|
|
|
|
$objRow->children = $this->getChildren($project_id, $objRow->id); |
|
|
|
|
$objRow->key = rand(1, 1000); |
|
|
|
|
$finalData[] = $objRow; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','data'=>$finalData,'code'=>200], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function getChildren($project_id, $parent_id) |
|
|
|
|
{ |
|
|
|
|
$finalData = []; |
|
|
|
|
$data = HierarchyFtth::where('project_id', $project_id)->where('parent_id', $parent_id)->orderByRaw('id ASC')->get(); |
|
|
|
|
foreach($data as $objRow){ |
|
|
|
|
$objRow->key = rand(1, 1000); |
|
|
|
|
$objRow->children = $this->getChildren($project_id, $objRow->id); |
|
|
|
|
$finalData[] = $objRow; |
|
|
|
|
} |
|
|
|
|
return $finalData; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|