本文整理汇总了PHP中app\Order::ReportGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::ReportGroup方法的具体用法?PHP Order::ReportGroup怎么用?PHP Order::ReportGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Order
的用法示例。
在下文中一共展示了Order::ReportGroup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Chart
public function Chart()
{
$yesterday = Carbon::now();
$start = $yesterday->copy()->addDays(-7);
$end = $yesterday->copy();
// for query
$startBetween = $start->format('Y-m-d');
$endBetween = $end->format('Y-m-d');
$dates = [];
while ($start->lte($end)) {
$dates[] = $start->copy();
$start->addDay();
}
$dates = collect($dates)->forPage(1, 7);
$reports = \App\Order::ReportGroup("(orders.`tanggal` BETWEEN '{$startBetween}' AND '{$endBetween}')", "GROUP BY tanggal");
$reports = ConvertRawQueryToArray($reports);
$dataLastWeek = [];
$dataLabelLastWeek = [];
foreach ($dates as $date) {
$idx = array_search($date->format("Y-m-d"), array_column($reports, "tanggal"));
$val = 0;
if (false !== $idx) {
$d = $reports[$idx];
$val = $d['jumlah'];
}
$dataLabelLastWeek[] = $date->format('d M Y');
$dataLastWeek[] = $val;
}
return ['label' => $dataLabelLastWeek, 'data' => $dataLastWeek];
}
示例2: _labaRugiPertahun
protected function _labaRugiPertahun(Request $request)
{
$tahun = $request->get('tahun') ? $request->get('tahun') : date('Y');
$penjualans = Order::ReportGroup("SUBSTRING(orders.`tanggal`, 1, 4) = '{$tahun}'", "GROUP BY SUBSTRING(tanggal, 1, 4)");
$penjualans = ConvertRawQueryToArray($penjualans);
$accountSaldo = \App\AccountSaldo::join('accounts', 'account_saldos.account_id', '=', 'accounts.id')->leftJoin(DB::raw("(SELECT accounts.`id` AS account_id, accounts.`nama_akun`, reports.display\n FROM accounts\n INNER JOIN account_report ON accounts.`id` = account_report.`account_id`\n INNER JOIN reports ON account_report.`report_id` = reports.id\n WHERE reports.key = 'labarugi')temp_report"), function ($join) {
$join->on('accounts.id', '=', 'temp_report.account_id');
})->where(DB::raw('SUBSTRING(account_saldos.tanggal, 1, 4)'), $tahun)->whereNull('account_saldos.relation_id')->whereNotNull('temp_report.account_id')->groupBy('accounts.id')->select(['accounts.nama_akun', DB::raw('SUM(account_saldos.nominal)total'), 'account_saldos.type'])->get()->groupBy('type');
$tableTemp = $this->buildLabaRugiTable(['penjualans' => $penjualans, 'account_saldo' => $accountSaldo]);
return ['tanggal' => Carbon::createFromFormat('Y', $tahun), 'tableTemp' => $tableTemp];
}