@extends('templates.main') @section('content') @php use Carbon\Carbon; function name_days($ke) { $tgl = date('Y-m-d', time() - 60 * 60 * 24 * $ke); $create = Carbon::create($tgl, 'Asia/Jakarta'); $grafik = $create->format('l'); if ($grafik == 'Monday') { $g = 'Senin'; } elseif ($grafik == 'Tuesday') { $g = 'Selasa'; } elseif ($grafik == 'Wednesday') { $g = 'Rabu'; } elseif ($grafik == 'Thursday') { $g = 'Kamis'; } elseif ($grafik == 'Friday') { $g = 'Jumat'; } elseif ($grafik == 'Saturday') { $g = 'Sabtu'; } elseif ($grafik == 'Sunday') { $g = 'Minggu'; } return $g; } @endphp

Saldo Anda

@if (auth()->user()->saldo > 500000)
Unlimited
@else
Rp {{ number_format(auth()->user()->saldo, 0, ',', '.') }}
@endif
@php $historyCount = App\Models\History::where('reseller', Auth::user()->name)->count(); @endphp

Total Transaksi

{{ $historyCount }}

@php $incode = App\Models\History::where('reseller', Auth::user()->name) ->selectRaw('SUM(REPLACE(REPLACE(harga, "Rp.", ""), ".", "")) as total_pendapatan') ->value('total_pendapatan'); @endphp

Role

{{ Auth::user()->level }}

Sales analysis
@php $pendapatan = App\Models\History::where('reseller', Auth::user()->name) ->selectRaw('SUM(REPLACE(REPLACE(harga, "Rp.", ""), ".", "")) as total_pendapatan') ->value('total_pendapatan'); $bulanini = App\Models\History::where('reseller', Auth::user()->name) ->whereMonth('created_at', now()->month) ->selectRaw('SUM(REPLACE(REPLACE(harga, "Rp.", ""), ".", "")) as total_pendapatan') ->value('total_pendapatan'); @endphp
  • Total Pendapatan

    Rp {{ number_format($pendapatan, 0, ',', '.') }}
  • Pendapatan Bulan Ini

    Rp {{ number_format($bulanini, 0, ',', '.') }}
@endsection @php // buatkan array dari januari sampai bulan ini, dan jika bulan ini adalah januari maka arraynya adalah januari saja 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(); $count = count($bulan); $register = []; $extended = []; foreach ($bulan as $key => $value) { $plus = $key + 1; $register[] = App\Models\History::where('barang', 'like', '%Order%') ->where('reseller', Auth::user()->name) ->whereMonth('created_at', $plus) ->count(); $extended[] = App\Models\History::where('barang', 'like', '%Perpanjang%') ->where('reseller', Auth::user()->name) ->whereMonth('created_at', $plus) ->count(); } @endphp @section('scripts') @endsection