Example #1
0
 /**
  * (Region, Branch, BranchOffice)
  * Group By BranchOffice for subtotal savings
  *
  * @param  stdClass $model
  * @param  array $branch
  * @return group array stdclass
  */
 public function collect_by_branchOffice($model, $branches, $branchesOffice = null, $segmentase)
 {
     if (is_array($branches) and is_array($branchesOffice)) {
         return $model->whereIn('savings_products.office_code', $branchesOffice)->whereIn('branch_office.category', $this->getBranchOffice($segmentase))->groupBy('savings_products.office_code', 'savings_products.date_report', 'product_of_savings.id')->get();
     } else {
         if (is_array($branches)) {
             return $model->where('savings_products.branch_code', '=', $branches)->whereIn('branch_office.category', array(1, 2, 3))->groupBy('savings_products.office_code', 'savings_products.date_report', 'product_of_savings.id')->get();
         }
     }
 }