当前位置: 首页>>代码示例>>PHP>>正文


PHP Helper::calculateParentDiscount方法代码示例

本文整理汇总了PHP中app\helpers\Helper::calculateParentDiscount方法的典型用法代码示例。如果您正苦于以下问题:PHP Helper::calculateParentDiscount方法的具体用法?PHP Helper::calculateParentDiscount怎么用?PHP Helper::calculateParentDiscount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\helpers\Helper的用法示例。


在下文中一共展示了Helper::calculateParentDiscount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: bill_class

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function bill_class($fee_schedule_code)
 {
     // dd($fee_schedule_code);
     $table = 'fee_sch_' . session()->get('current_session') . '_' . session()->get('current_term');
     $fee_schedule = DB::table($table)->where('fee_schedule_code', $fee_schedule_code)->first();
     $amount = DB::table($table)->where('fee_schedule_code', $fee_schedule_code)->sum('amount');
     $students = Student::where('class_id', $fee_schedule->class_id)->get();
     $school = School::find(1);
     //get all studenta ids who are eligible for the parent discount
     if ($school->parent_discount == 1) {
         $children_number = DiscountPolicy::find(1)->children_number;
         if ($children_number == null) {
             session()->flash('flash_message', 'Please, set the parent discount values. Go to Billing-> Discount Policies.');
             return redirect()->back();
         }
         $parent_discount_eligible = Helper::getParentDiscountEligibles();
         sort($parent_discount_eligible);
     }
     // dd($parent_discount_eligible);
     foreach ($students as $student) {
         $discount = 0;
         //get parent discount
         if ($school->parent_discount == 1) {
             if (in_array($student->id, $parent_discount_eligible)) {
                 $discount = Helper::calculateParentDiscount($student->id, $fee_schedule_code);
                 // dd($discount);
             }
         }
         //calculate total amount due to be paid
         $total = $amount - $discount;
         try {
             \DB::table('invoices_' . \Session::get('current_session') . '_' . \Session::get('current_term'))->insert(['student_id' => $student->id, 'fee_schedule_code' => $fee_schedule_code, 'invoice_number' => str_replace('-', '', $fee_schedule_code) . str_pad($student->id, 3, '0', STR_PAD_LEFT), 'amount' => $amount, 'discount' => $discount, 'balance' => Helper::getStudentCurrentBalance($student->id), 'total' => $total]);
         } catch (\Illuminate\Database\QueryException $e) {
             $errorCode = $e->errorInfo[1];
             if ($errorCode == 1062) {
                 session()->flash('flash_message', 'Hey, these guys have been invoiced');
                 return \Redirect::back();
             }
         }
     }
     //change the status of the fee schedule after billing class
     DB::table($table)->where('fee_schedule_code', $fee_schedule_code)->update(['status_id' => 8]);
     return redirect()->to('billing/invoices');
 }
开发者ID:umahatokula,项目名称:academia,代码行数:50,代码来源:invoicesController.php


注:本文中的app\helpers\Helper::calculateParentDiscount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。