Why my data record is 0?
Closed this issue · 3 comments
iammul commented
`public function index()
{
$chart_options = [
'chart_title' => 'Transactions by dates',
'report_type' => 'group_by_date',
'model' => 'App\Transaction',
'group_by_field' => 'created_at',
'group_by_period' => 'day',
'aggregate_function' => 'sum',
'aggregate_field' => 'amount',
'chart_type' => 'line',
];
$chart = new LaravelChart($chart_options);
return view('pages.bendahara.dashboard', [
'chart' => $chart,
'daily' => Transaction::where('created_at', '>=', now())
->get()
->sum('transaction_total'),
'not_checked' => Transaction::where('is_checked', 0)->count(),
'transaction_success' => Transaction::where(
'transaction_status',
'SUCCESS'
)->count(),
]);
}`
my blade
`@extends('layouts.bendahara')
@section('content')
<!-- Begin Page Content -->
<div class="container-fluid">
<!-- Page Heading -->
<div class="d-sm-flex align-items-center justify-content-between mb-4">
<h1 class="h3 mb-0 text-gray-800">Dashboard</h1>
</div>
<!-- Content Row -->
<div class="row">
<!-- Earnings (Monthly) Card Example -->
<div class="col-xl-4 col-md-6 mb-4">
<div class="card border-left-success shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-success text-uppercase mb-1">
Transaksi Hari Ini</div>
<div class="h5 mb-0 font-weight-bold text-gray-800">{{ $daily }}</div>
</div>
<div class="col-auto">
<i class="fas fa-dollar-sign fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
<!-- Earnings (Monthly) Card Example -->
<div class="col-xl-4 col-md-6 mb-4">
<div class="card border-left-info shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-info text-uppercase mb-1">Ticket Not Checked
</div>
<div class="row no-gutters align-items-center">
<div class="col-auto">
<div class="h5 mb-0 mr-3 font-weight-bold text-gray-800">{{ $not_checked }}</div>
</div>
</div>
</div>
<div class="col-auto">
<i class="fas fa-spinner fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
<!-- Pending Requests Card Example -->
<div class="col-xl-4 col-md-6 mb-4">
<div class="card border-left-warning shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-warning text-uppercase mb-1">
Sukses</div>
<div class="h5 mb-0 font-weight-bold text-gray-800">{{ $transaction_success }}</div>
</div>
<div class="col-auto">
<i class="fas fa-check fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<!-- Area Chart -->
<div class="col-xl-12 col-lg-11">
<div class="card shadow mb-4">
<!-- Card Header - Dropdown -->
<div
class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
<h6 class="m-0 font-weight-bold text-primary">{{ $chart->options['chart_title'] }}</h6>
</div>
<!-- Card Body -->
<div class="card-body">
{!! $chart->renderHtml() !!}
</div>
</div>
</div>
</div>
</div>
<!-- /.container-fluid -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
{!! $chart->renderChartJsLibrary() !!}
{!! $chart->renderJs() !!}
iammul commented
btw im using laravel 6
PovilasKorop commented
@iammul from what I see you're doing sum from "amount" and your field is actually called "transaction_total".
iammul commented
@PovilasKorop thankyouu sirr, I guess I have to read the documentation again 🥲