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


PHP Student::with方法代码示例

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


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

示例1: adminGraph

 public function adminGraph()
 {
     $result = ['newcomers' => [], 'orga' => ['wei' => 0, 'sandwitch' => 0, 'guarantee' => 0], 'ce' => ['wei' => 0, 'sandwitch' => 0, 'guarantee' => 0], 'vieux' => ['wei' => 0, 'sandwitch' => 0, 'guarantee' => 0]];
     $newscomers = Newcomer::with('weiPayment', 'sandwichPayment', 'guaranteePayment')->get();
     $students = Student::with('weiPayment', 'sandwichPayment', 'guaranteePayment')->get();
     foreach ($newscomers as $newcomer) {
         if (!isset($result['newcomers'][$newcomer->branch])) {
             $result['newcomers'][$newcomer->branch] = [];
             $result['newcomers'][$newcomer->branch]['wei'] = 0;
             $result['newcomers'][$newcomer->branch]['sandwitch'] = 0;
             $result['newcomers'][$newcomer->branch]['guarantee'] = 0;
         }
         if (isset($newcomer->weiPayment) && $newcomer->weiPayment->state == 'paid') {
             $result['newcomers'][$newcomer->branch]['wei'] += 1;
         }
         if (isset($newcomer->sandwichPayment) && $newcomer->sandwichPayment->state == 'paid') {
             $result['newcomers'][$newcomer->branch]['sandwitch'] += 1;
         }
         if (isset($newcomer->guaranteePayment) && $newcomer->guaranteePayment->state == 'paid') {
             $result['newcomers'][$newcomer->branch]['guarantee'] += 1;
         }
     }
     foreach ($students as $student) {
         $ret =& $result['vieux'];
         if ($student->ce && $student->team_accepted && $student->team_id) {
             $ret =& $result['ce'];
         } elseif ($student->orga) {
             $ret =& $result['orga'];
         }
         if (isset($student->weiPayment) && $student->weiPayment->state == 'paid') {
             $ret['wei'] += 1;
         }
         if (isset($student->sandwichPayment) && $student->sandwichPayment->state == 'paid') {
             $ret['sandwitch'] += 1;
         }
         if (isset($student->guaranteePayment) && $student->guaranteePayment->state == 'paid') {
             $ret['guarantee'] += 1;
         }
     }
     $graphPaid = Payment::select(DB::raw('DATE_FORMAT(created_at,\'%d-%m-%Y\') as day'), DB::raw('COUNT(id) as sum'))->where('type', 'payment')->where('state', 'paid')->where('amount', '>', 325)->orderBy('created_at')->groupBy(DB::raw('DATE_FORMAT(created_at,\'%d-%m-%Y\')'))->get();
     $graphCaution = Payment::select(DB::raw('DATE_FORMAT(created_at,\'%d-%m-%Y\') as day'), DB::raw('COUNT(id) as sum'))->where('type', 'guarantee')->where('state', 'paid')->orderBy('created_at')->groupBy(DB::raw('DATE_FORMAT(created_at,\'%d-%m-%Y\')'))->get();
     $graphFood = Payment::select(DB::raw('DATE_FORMAT(created_at,\'%d-%m-%Y\') as day'), DB::raw('COUNT(id) as sum'))->where('type', 'payment')->where(DB::raw('`amount`%500'), 325)->where('state', 'paid')->orderBy('created_at')->groupBy(DB::raw('DATE_FORMAT(created_at,\'%d-%m-%Y\')'))->get();
     $sum = ['paid' => array_sum(array_column($graphPaid->toArray(), 'sum')), 'caution' => array_sum(array_column($graphCaution->toArray(), 'sum')), 'food' => array_sum(array_column($graphFood->toArray(), 'sum'))];
     return View::make('dashboard.wei.graph', ['graphPaid' => $graphPaid, 'graphCaution' => $graphCaution, 'graphFood' => $graphFood, 'sum' => $sum, 'global' => $result]);
 }
开发者ID:ungdev,项目名称:integration-UTT,代码行数:45,代码来源:WEIController.php


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