@php use App\Models\Demography; $Field=DB::table('DemographyConfig')->where('DemographyConfigId',$demographyconfigId)->get()->first(); $DisplayName=$Field->LabelValue; $ColumnName=$Field->ColumnName; $PModuleId=$Field->ModuleId; $LabelValue=$columnname; $dispRelatedValue=""; $ParentModuleId=$Field->ParentModuleId; $ParentRowId=''; $ParentField=DB::table('DemographyConfig')->where('ModuleId',$ParentModuleId)->where('ReferenceField',1)->get(['ColumnName'])->first(); try { $ParentField=$ParentField->ColumnName; } catch(\Exception $e) { $ParentField=DB::table('DemographyConfig')->where('ModuleId',$ParentModuleId)->where('ColumnName','%like%','Name')->get(['ColumnName'])->first(); try { $ParentField=$ParentField->ColumnName; } catch(\Exception $e) { $ParentField="CreatedDate"; } } $RelatedNames=[]; @endphp