feat(overview): membuat tabel untuk pendapatan by barber
This commit is contained in:
parent
84fb7885ad
commit
d2200d6006
@ -15,11 +15,35 @@ class OverviewController extends Controller
|
|||||||
{
|
{
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$todayIncome = Transaction::query()->barbershop()->whereDate('created_at', now()->today())->sum('total');
|
$todayIncome = Transaction::query()
|
||||||
$yesterdayIncome = Transaction::query()->barbershop()->whereDate('created_at', now()->yesterday())->sum('total');
|
->barbershop()
|
||||||
|
->whereDate('created_at', now()->today())
|
||||||
|
->when(auth()->user()->role_id === 5, function ($query) {
|
||||||
|
return $query->where('user_id', auth()->id());
|
||||||
|
})
|
||||||
|
->sum('total');
|
||||||
|
$yesterdayIncome = Transaction::query()
|
||||||
|
->barbershop()
|
||||||
|
->whereDate('created_at', now()->yesterday())
|
||||||
|
->when(auth()->user()->role_id === 5, function ($query) {
|
||||||
|
return $query->where('user_id', auth()->id());
|
||||||
|
})
|
||||||
|
->sum('total');
|
||||||
|
|
||||||
$todayShaving = Transaction::query()->barbershop()->today()->count();
|
$todayShaving = Transaction::query()
|
||||||
$yesterdayShaving = Transaction::query()->barbershop()->yesterday()->count();
|
->barbershop()
|
||||||
|
->today()
|
||||||
|
->when(auth()->user()->role_id === 5, function ($query) {
|
||||||
|
return $query->where('user_id', auth()->id());
|
||||||
|
})
|
||||||
|
->count();
|
||||||
|
$yesterdayShaving = Transaction::query()
|
||||||
|
->barbershop()
|
||||||
|
->yesterday()
|
||||||
|
->when(auth()->user()->role_id === 5, function ($query) {
|
||||||
|
return $query->where('user_id', auth()->id());
|
||||||
|
})
|
||||||
|
->count();
|
||||||
|
|
||||||
$todayExpense = Expense::query()->barbershop()->today()->sum('amount');
|
$todayExpense = Expense::query()->barbershop()->today()->sum('amount');
|
||||||
$yesterdayExpense = Expense::query()->barbershop()->yesterday()->sum('amount');
|
$yesterdayExpense = Expense::query()->barbershop()->yesterday()->sum('amount');
|
||||||
@ -50,6 +74,13 @@ public function index()
|
|||||||
->limit(5)
|
->limit(5)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
$incomeByBarber = User::with('biography')
|
||||||
|
->barbershop()
|
||||||
|
->barber()
|
||||||
|
->withSum('transactions', 'total')
|
||||||
|
->withCount('transactions')
|
||||||
|
->get();
|
||||||
|
|
||||||
return view('pages.admin.dashboard.overview', [
|
return view('pages.admin.dashboard.overview', [
|
||||||
'pageTitle' => 'Ringkasan',
|
'pageTitle' => 'Ringkasan',
|
||||||
'todayIncome' => $todayIncome,
|
'todayIncome' => $todayIncome,
|
||||||
@ -62,6 +93,7 @@ public function index()
|
|||||||
'yesterdayNewCustomer' => $yesterdayNewCustomer,
|
'yesterdayNewCustomer' => $yesterdayNewCustomer,
|
||||||
'cash' => Barbershop::findOrFail(Auth::user()->barbershop_id)->cash,
|
'cash' => Barbershop::findOrFail(Auth::user()->barbershop_id)->cash,
|
||||||
'topCustomersByTotal' => $topCustomersByTotal,
|
'topCustomersByTotal' => $topCustomersByTotal,
|
||||||
|
'incomeByBarber' => $incomeByBarber,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -132,6 +132,35 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header card-no-border">
|
||||||
|
<div class="header-top">
|
||||||
|
<h5 class="m-0">Pendapatan Barber</h5>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-body pt-0">
|
||||||
|
<div class="table-responsive custom-scrollbar">
|
||||||
|
<table class="table table-dashed">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Nama</th>
|
||||||
|
<th>Jumlah Transaksi</th>
|
||||||
|
<th>Total Transakski</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach ($incomeByBarber as $item)
|
||||||
|
<tr>
|
||||||
|
<td>{{ $item->biography->full_name ?? '--deleted--' }}</td>
|
||||||
|
<td>{{ $item->transactions_count }}</td>
|
||||||
|
<td>{{ formatToRupiah($item->transactions_sum_total) }}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user