@if (count($courier_orders) <= 4) @php $x = ceil(count($courier_orders) / 2); @endphp @else @php $y = ceil(count($courier_orders) / 2); $x = ceil(count($courier_orders) / $y); @endphp @endif @foreach (array_chunk($courier_orders, $x) as $orders) @foreach ($orders as $data) @php $setting = App\Setting::first(); $city = \App\City::where('id', $setting->city)->first(); $sale_id = $data['sale_id']; $sale = \Illuminate\Support\Facades\DB::table('sales') ->where('sales.id', $sale_id) ->join('contacts', 'sales.contact_id', '=', 'contacts.id') ->leftjoin('districts', 'contacts.district_id', '=', 'districts.id') ->leftjoin('cities', 'contacts.city', '=', 'cities.id') ->select('sales.*', 'contacts.*', 'districts.name_en as districtName', 'cities.name_en as cityName') ->first(); try { $item_names = DB::table('sale_items') ->join('product_has_attribute_value', 'sale_items.product_id', '=', 'product_has_attribute_value.product_id') ->where('sale_items.sale_id', $sale_id) ->whereNull('sale_items.deleted_at') ->select('sale_items.*', 'product_has_attribute_value.sku','product_has_attribute_value.attribute_value_id') ->get(); // You can process $item_names here } catch (QueryException $e) { // Handle the query exception here // Log the error message or return a response \Log::error('Query Error: ' . $e->getMessage()); // You can also throw a custom error or return a specific response return response()->json(['error' => 'Unable to fetch sale items'], 500); } $wocommance_user = \App\WoocommerceUser::where('id', $sale->woocommerce_user_id)->first(); @endphp @endforeach @endforeach
Order No :{{ $sale->invoice_no }}

To
product_sku_enable != '1') style="display: none" @endif> sale_note_enable != '1') style="display: none" @endif>
Name : {!! $sale->name !!}
Address : {!! $sale->landmark !!} , @if ($sale->cityName != 'Other') product_sku_enable == '1') style="display: none" @endif> {!! $sale->cityName !!} @endif
Contact No : {!! $sale->mobile !!} @if (!empty($sale->mobile_2)) / {!! $sale->mobile_2 !!} @endif
Sku : @php // Get all attribute values needed for the items in one query $attributeIds = $item_names->pluck('attribute_value_id')->filter(); // Get non-null IDs $attributes = \Illuminate\Support\Facades\DB::table('attribute_values') ->whereIn('id', $attributeIds) ->get() ->keyBy('id'); // Collect attributes by ID for easier lookup $totalQty = 0; @endphp @foreach ($item_names as $item) @php // Get the attribute value if it exists $attribute = $attributes->get($item->attribute_value_id); $totalQty += $item->qty; @endphp {{-- {{ dd($attribute)}} --}} @if (!empty($item->sku)) @php $products = \Illuminate\Support\Facades\DB::table('product_has_attribute_value') ->where('sku', $item->sku) ->first(); $product_find = \Illuminate\Support\Facades\DB::table('products') ->where('id', $products->product_id) ->first(); @endphp @if ($attribute == null) {{ $product_find->product_name.' / ' }}{{ $item->qty }}, @else {{ $product_find->product_name.' / ' }}{{ $attribute->value.' / ' }}{{ $item->qty }}, @endif @else N/A @endif @endforeach
Total Qty: {{ $totalQty }}
Sale Note : @if (!empty($sale->sale_note)) {{ $sale->sale_note }} @else N/A @endif

From
@if ($setting->woocommerce_user_wise_report != '1') @else @endif
Name : {{ $setting->name }}
Name : @if (!empty($wocommance_user->username)) {{ $wocommance_user->username }} @else ShoppyMax.LK @endif
Address : {{ $setting->landmark }} , {{ $setting->landmark_2 }} , @if ($city) {{ $city->name_en }} @endif
Contact No : {{ $setting->mobile }}

@if ($sale->payment_status == 'due') COD : @if (!empty($sale->currency_type)) @if ($sale->currency_type == 'usd') @php $total = $sale->invoice_nettotal / $setting->currency_rate; @endphp {{ number_format($total, 2) }} $ @else {{ number_format($sale->invoice_nettotal, 2) }} LKR {{-- {{ $sale->currency_type == 'usd' ? '$' : 'LKR' }} --}} @endif @else LKR @endif @elseif ($sale->payment_status == 'partial') Balance : @if (!empty($sale->currency_type)) @if ($sale->currency_type == 'usd') @php $total = $sale->invoice_balance / $setting->currency_rate; @endphp {{ number_format($total, 2) }} $ @else {!! number_format($sale->invoice_balance, 2) !!} LKR @endif @else LKR @endif @else FREE @endif

barcode
{{ $sale->waybill_prefix . $sale->waybill_no . $sale->waybill_postfix }}