/** * (Region, Branch, BranchOffice) * Group By Branch for subtotal savings * * @param stdClass $model * @param array $branch * @return group array stdclass */ public function collect_by_branch($model, $branches) { /** * @event : branch ( branch total, grandtotal ) * @param array $branches (must be array) * @return stdclass branch */ if (is_array($branches)) { return $model->WhereIn('savings_products.branch_code', $branches)->groupBy('savings_products.branch_code', 'savings_products.date_report', 'product_of_savings.id')->orderBy('savings_products.branch_code')->get(); } else { return $model->Where('savings_products.branch_code', $branches)->groupBy('savings_products.branch_code', 'savings_products.date_report', 'product_of_savings.id')->get(); } }