where('rfi_no', 'like', '%' . $rfiNo . '%'); } if(!empty($discipline)) { $query->where('discipline', $discipline); } if(!empty($projectNo)) { $query->where('project_no', $projectNo); } // Total count for pagination $totalCount = $query->count(); // Sıralama: En son girilen önce, sonra RFI tarihine göre // Pagination uygula $rfiData = $query ->orderBy('id', 'DESC') // En son girilen önce ->orderBy('inspection_date', 'ASC') // Inspection tarihine göre sıralı ->skip($skip) ->take($take) ->get(); // Verileri formatla foreach($rfiData as $item) { $row = [ 'id' => $item->id, 'rfi_no' => $item->rfi_no, 'inspection_date' => $item->inspection_date, 'discipline' => $item->discipline, 'project_no' => $item->project_no, 'itp' => $item->itp, 'status' => $item->status, 'subcontractor' => $item->subcontractor, 'contractor' => $item->contractor, 'unit' => $item->unit, 'area' => $item->area, 'location' => $item->location, 'description' => $item->description, ]; $response[] = $row; } // JSON formatında yanıt döndür echo json_encode($response); ?>