@extends('templates.main') @section('content') @php use Carbon\Carbon; $userName = Auth::user()->name; $historyQuery = App\Models\History::where('reseller', $userName); $historyCount = $historyQuery->count(); $pendapatan = (clone $historyQuery) ->selectRaw('SUM(REPLACE(REPLACE(harga, "Rp.", ""), ".", "")) as total') ->value('total'); $bulanini = (clone $historyQuery) ->whereMonth('created_at', now()->month) ->selectRaw('SUM(REPLACE(REPLACE(harga, "Rp.", ""), ".", "")) as total') ->value('total'); function get_months_until_now($format = 'F') { $months = []; for ($i = 1; $i <= now()->month; $i++) { $months[] = now()->startOfMonth()->subMonths($i - 1)->format($format); } return array_reverse($months); } $bulan = get_months_until_now(); $register = []; $extended = []; foreach ($bulan as $key => $value) { $plus = $key + 1; $register[] = (clone $historyQuery)->where('barang', 'like', '%Order%')->whereMonth('created_at', $plus)->count(); $extended[] = (clone $historyQuery)->where('barang', 'like', '%Perpanjang%')->whereMonth('created_at', $plus)->count(); } @endphp

Selamat datang,

{{ $userName }}

Total Saldo
@if (auth()->user()->saldo > 500000)
Unlimited
@else
Rp {{ number_format(auth()->user()->saldo, 0, ',', '.') }}
@endif
{{ Auth::user()->level }} Access
Total Transaksi
{{ $historyCount }}
Bulan Ini
Rp {{ number_format($bulanini / 1000, 0, ',', '.') }}K
Aktivitas
Total Pendapatan
Sejak bergabung
Rp {{ number_format($pendapatan, 0, ',', '.') }}
Bulan Ini
{{ now()->format('F Y') }}
Rp {{ number_format($bulanini, 0, ',', '.') }}
@endsection @section('scripts') @endsection