@php $common = \App\Models\Common::class; $type = 'sell'; $reference_id = $sell_id; if($receipt_id) { $type = 'sell_receipt'; $reference_id = $receipt_id; } if($payment_voucher_id){ $type = 'payment_voucher'; $reference_id = $payment_voucher_id; } $document = \App\Models\DocumentPrint::where('document_name',$document_name)->first(); $document_details = \App\Models\DocumentPrintDetails::where('document_id',$document->id)->get(); $field_bank = $common::getDesignerFieldsBank($reference_id,$type); @endphp @php $background_img = ($document->img_url); $page_size = $document->document_height*96; $page_fields = []; $pages = $pages ?? []; foreach (range(1,$document->no_of_pages) as $page ) { $page_fields[$page] = []; } foreach ($document_details as $key => $document_detail) { $y_coordinate = $document_detail->y_coordinate; $page = floor($y_coordinate / $page_size)+1; $page_fields[$page][] = $document_detail; } if(count($pages) > 0){ foreach($page_fields as $key => $value){ if(!in_array($key , $pages)){ unset($page_fields[$key]); } } } @endphp