本文整理汇总了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]);
}