I have to remove the parent array if the contain is not available or empty. In below code if supplierOffer is empty then I have to remove the SupplierInquiry array but here I am getting the SupplierInquiry array with empty supplierOffer. I cann't unset by using foreach loop because then the count will show wrong. Any solution for this issue?
$this->paginate = [
'contain'=>['SupplierOffer'=>function($q){
return $q->where(['SupplierOffer.status IS NULL']);
},'CompanyMaster','SupplierOffer.PurchaseOrder','SupplierOffer.SupplierOfferProducts','SupplierOffer.SupplierOfferProducts.ProductsMaster','SupplierOffer.SupplierOfferProducts.Uom','SupplierOffer.SupplierOfferProducts.Currency', 'OwnerCompanies','SupplierOffer.CompanyMaster','SupplierOffer.SupplierOfferProducts.PrSuppliers'],
'order'=>['SupplierInquiry.id' => 'DESC'],
'conditions'=>[$condn,$conditions,'SupplierOffer IS NOT NULL'],
];
$supplierOffer = $this->paginate($this->SupplierInquiry);