@include('layouts.header', ['title' => isset($project) ? 'Project Survey Details' : 'Add Project'])
@include('layouts.navbar') @include('layouts.sidebar')
@include('components.project-details', ['project' => $project])
Reset
@if ($structure_use == '1')

Survey Lists

@if ($surveys->isEmpty()) @else @foreach ($surveys as $survey) @if ($survey->structure_use == '1') @endif @endforeach @endif
Sl. No. Map No. Identification No. Name of the Owner Name of the Occupant of structure Type of Structure Carpet Area(In Sq.mtr.) Type of Use Occupancy Status Year of Settlement Zopdi No. PAP Name Survey Date Action
No Records Found
{{ $loop->iteration + ($surveys->currentPage() - 1) * $surveys->perPage() }} 1 1 @if ($survey->SurveyUserResidential->isNotEmpty()) {{ $survey->SurveyUserResidential->pluck('structure_owner_name')->implode(', ') }} @else N/A @endif @if ($survey->SurveyUserResidential->isNotEmpty()) {{ $survey->SurveyUserResidential->pluck('name_occupant_structure')->implode(', ') }} @else N/A @endif @if ($survey->SurveyUserResidentialSocioEconomicIndicator->isNotEmpty()) {{ $survey->SurveyUserResidentialSocioEconomicIndicator->map(function ($item) { return $item->structureRoof->name . ', ' . $item->structureWall->name . ', ' . $item->structureFloor->name; })->implode(', ') ?? 'N/A' }} @else N/A @endif @if ($survey->SurveyUserResidential->isNotEmpty()) {{ $survey->SurveyUserResidential->pluck('total_area')->implode(', ') }} @else N/A @endif @if ($survey->structure_use == '1') Residential @else N/A @endif @if ($survey->SurveyUserResidential->isNotEmpty()) {{ $survey->SurveyUserResidential->pluck('structureHolder.name')->implode(', ') ?? 'N/A' }} @else N/A @endif 2000002 {{ $survey->structure_id ?? 'N/A' }} {{ $survey->pap_name ?? 'N/A' }} {{ $survey->survey_date ? date('d M Y', strtotime($survey->survey_date)) : 'N/A' }}
{{ $surveys->appends(request()->query())->links('pagination::bootstrap-5') }}
@endif {{-- other --}} @if ($structure_use == '4')

Survey Lists

@foreach ($surveys as $key => $survey) @if ($survey->structure_use == '4') @endif @endforeach
Sl. No. Zopdi No. PAP Name Survey Date Action
{{ $loop->index + 1 + ($surveys->currentPage() - 1) * $surveys->perPage() }} {{ $survey->structure_id }} {{ $survey->pap_name }} {{ $survey->survey_date ? date('d M Y', strtotime($survey->survey_date)) : 'N/A' }}
{{ $surveys->appends(request()->query())->links('pagination::bootstrap-5') }}
@endif
@include('layouts.footer')
public function projectSurveyLists(Request $request, $projectId) { $projectId = decrypt($projectId); $project = $this->rnrRepo->getProjectById($projectId); // Check if the user is authorized if (Auth::user()->user_role_id !== 1 && $project->sdc_officer_user_id !== Auth::id()) { abort(403, 'Unauthorized access.'); } $searchName = request()->query('pap_name'); $filterType = $request->query('filter_type'); // Get filter type from AJAX // Paginate surveys $surveys = Survey::where('project_id', $projectId) ->when($searchName, function ($query) use ($searchName) { $query->where('pap_name', 'like', '%' . $searchName . '%'); }) ->paginate(5); // Set structure_use based on the first survey or default to a value $structure_use = $surveys->isNotEmpty() ? $surveys->first()->structure_use : null; // Loop over actual items, not the paginator foreach ($surveys->items() as $survey) { if ($filterType == 'A5') { $survey->load('surveyUserOthers.structureType'); } elseif ($filterType == 'A2') { $survey->load(['surveyUserCommercial.shopType', 'surveyUserCommercial.workersType']); } elseif ($filterType == 'A1') { $survey->load([ 'surveyUserResidential.structureHolder', 'surveyUserResidential.motherTongue', 'surveyUserResidential.casteGroup', 'surveyUserResidential.religion', // 'surveyUserResidentialHouseholdMembers.relation', // 'surveyUserResidentialHouseholdMembers.gender', // 'surveyUserResidentialVulnerability', // 'SurveyUserResidentialSocioEconomicIndicator.typesOfStructures', // 'SurveyUserResidentialSocioEconomicIndicator.floors', // 'SurveyUserResidentialSocioEconomicIndicator.rooms', 'SurveyUserResidentialSocioEconomicIndicator.structureRoof', 'SurveyUserResidentialSocioEconomicIndicator.structureWall', 'SurveyUserResidentialSocioEconomicIndicator.structureFloor', // 'SurveyUserResidentialSocioEconomicIndicator.toiletType', // 'SurveyUserResidentialSocioEconomicIndicator.WaterType', // 'SurveyUserResidentialSocioEconomicIndicator.EstimateAnnualExpenditure', // 'SurveyUserResidentialSocioEconomicIndicator.CookingFuel' ]); } } // dd(json_encode($surveys)); $users = User::whereHas('designated', function ($query) { $query->where('status', '1'); })->with('designated')->get(); return view('admin.RnRProjects.project-survey-list', compact('project', 'surveys', 'users', 'structure_use')); }