From 08e13658fde10b1fa7c919d9863613a97eed4a2d Mon Sep 17 00:00:00 2001 From: LailaWulandarii Date: Tue, 27 Jan 2026 17:21:20 +0700 Subject: [PATCH] add ProfilRequest for request validation structure in Admin --- .../Controllers/Admin/BerandaController.php | 97 +++++++++++-------- app/Http/Requests/Admin/ProfilRequest.php | 28 ++++++ 2 files changed, 82 insertions(+), 43 deletions(-) create mode 100644 app/Http/Requests/Admin/ProfilRequest.php diff --git a/app/Http/Controllers/Admin/BerandaController.php b/app/Http/Controllers/Admin/BerandaController.php index 5f9a2fb..6fa075c 100644 --- a/app/Http/Controllers/Admin/BerandaController.php +++ b/app/Http/Controllers/Admin/BerandaController.php @@ -7,55 +7,66 @@ use App\Models\BookingFoto; use Carbon\Carbon; use Illuminate\Support\Facades\DB; +use App\Services\DashboardService; class BerandaController extends Controller { public function index() { - $now = Carbon::now(); - $lastMonth = Carbon::now()->subMonth(); $today = Carbon::today(); - $getGrowth = function ($current, $previous) { - if ($previous <= 0) return $current > 0 ? 100 : 0; - return round((($current - $previous) / $previous) * 100, 1); - }; - $currPendapatan = TransaksiBuket::whereMonth('created_at', $now->month)->whereYear('created_at', $now->year)->where('status_transaksi', 'diterima')->sum('total_bayar') + - BookingFoto::whereMonth('created_at', $now->month)->whereYear('created_at', $now->year)->where('status_booking', 'diterima')->sum('total_bayar'); - - $currMasuk = TransaksiBuket::whereMonth('created_at', $now->month)->whereYear('created_at', $now->year)->count() + - BookingFoto::whereMonth('created_at', $now->month)->whereYear('created_at', $now->year)->count(); - - $currSelesai = TransaksiBuket::whereMonth('created_at', $now->month)->whereYear('created_at', $now->year)->where('status_transaksi', 'selesai')->count() + - BookingFoto::whereMonth('created_at', $now->month)->whereYear('created_at', $now->year)->where('status_booking', 'selesai')->count(); - - $currBatal = TransaksiBuket::whereMonth('created_at', $now->month)->whereYear('created_at', $now->year)->where('status_transaksi', 'ditolak')->count() + - BookingFoto::whereMonth('created_at', $now->month)->whereYear('created_at', $now->year)->where('status_booking', 'ditolak')->count(); - $prevPendapatan = TransaksiBuket::whereMonth('created_at', $lastMonth->month)->whereYear('created_at', $lastMonth->year)->where('status_transaksi', 'diterima')->sum('total_bayar') + - BookingFoto::whereMonth('created_at', $lastMonth->month)->whereYear('created_at', $lastMonth->year)->where('status_booking', 'diterima')->sum('total_bayar'); - - $prevMasuk = TransaksiBuket::whereMonth('created_at', $lastMonth->month)->whereYear('created_at', $lastMonth->year)->count() + - BookingFoto::whereMonth('created_at', $lastMonth->month)->whereYear('created_at', $lastMonth->year)->count(); - - $prevSelesai = TransaksiBuket::whereMonth('created_at', $lastMonth->month)->whereYear('created_at', $lastMonth->year)->where('status_transaksi', 'selesai')->count() + - BookingFoto::whereMonth('created_at', $lastMonth->month)->whereYear('created_at', $lastMonth->year)->where('status_booking', 'selesai')->count(); - - $prevBatal = TransaksiBuket::whereMonth('created_at', $lastMonth->month)->whereYear('created_at', $lastMonth->year)->where('status_transaksi', 'ditolak')->count() + - BookingFoto::whereMonth('created_at', $lastMonth->month)->whereYear('created_at', $lastMonth->year)->where('status_booking', 'ditolak')->count(); - $stat = [ - 'pendapatan' => $currPendapatan, - 'pendapatan_grow' => $getGrowth($currPendapatan, $prevPendapatan), - 'masuk_count' => $currMasuk, - 'masuk_grow' => $getGrowth($currMasuk, $prevMasuk), - 'selesai_count' => $currSelesai, - 'selesai_grow' => $getGrowth($currSelesai, $prevSelesai), - 'batal_count' => $currBatal, - 'batal_grow' => $getGrowth($currBatal, $prevBatal), - ]; - $buketToday = TransaksiBuket::with(['pelanggan', 'buket'])->whereDate('tgl_ambil', $today)->where('status_transaksi', 'diterima')->get(); - $fotoToday = BookingFoto::with(['pelanggan', 'paketFoto'])->whereDate('tgl_booking', $today)->where('status_booking', 'diterima')->orderBy('jam_mulai', 'asc')->get(); - $pesananBuket = TransaksiBuket::with(['pelanggan', 'buket'])->where('status_transaksi', 'menunggu_verifikasi')->latest()->get(); - $pesananFoto = BookingFoto::with(['pelanggan', 'paketFoto'])->where('status_booking', 'menunggu_verifikasi')->latest()->get(); - + $stat = DashboardService::getStats(); + $buketToday = TransaksiBuket::with(['pelanggan', 'buket'])->whereDate('tgl_ambil', $today)->where('status_transaksi', 'diterima')->get(); + $fotoToday = BookingFoto::with(['pelanggan', 'paketFoto'])->whereDate('tgl_booking', $today)->where('status_booking', 'diterima')->orderBy('jam_mulai', 'asc')->get(); + $pesananBuket = TransaksiBuket::where('status_transaksi', 'menunggu_verifikasi')->latest()->get(); + $pesananFoto = BookingFoto::where('status_booking', 'menunggu_verifikasi')->latest()->get(); return view('admin.beranda.index', compact('stat', 'buketToday', 'fotoToday', 'pesananBuket', 'pesananFoto')); } + // public function index() + // { + // $now = Carbon::now(); + // $lastMonth = Carbon::now()->subMonth(); + // $today = Carbon::today(); + // $getGrowth = function ($current, $previous) { + // if ($previous <= 0) return $current > 0 ? 100 : 0; + // return round((($current - $previous) / $previous) * 100, 1); + // }; + // $currPendapatan = TransaksiBuket::whereMonth('created_at', $now->month)->whereYear('created_at', $now->year)->where('status_transaksi', 'diterima')->sum('total_bayar') + + // BookingFoto::whereMonth('created_at', $now->month)->whereYear('created_at', $now->year)->where('status_booking', 'diterima')->sum('total_bayar'); + + // $currMasuk = TransaksiBuket::whereMonth('created_at', $now->month)->whereYear('created_at', $now->year)->count() + + // BookingFoto::whereMonth('created_at', $now->month)->whereYear('created_at', $now->year)->count(); + + // $currSelesai = TransaksiBuket::whereMonth('created_at', $now->month)->whereYear('created_at', $now->year)->where('status_transaksi', 'selesai')->count() + + // BookingFoto::whereMonth('created_at', $now->month)->whereYear('created_at', $now->year)->where('status_booking', 'selesai')->count(); + + // $currBatal = TransaksiBuket::whereMonth('created_at', $now->month)->whereYear('created_at', $now->year)->where('status_transaksi', 'ditolak')->count() + + // BookingFoto::whereMonth('created_at', $now->month)->whereYear('created_at', $now->year)->where('status_booking', 'ditolak')->count(); + // $prevPendapatan = TransaksiBuket::whereMonth('created_at', $lastMonth->month)->whereYear('created_at', $lastMonth->year)->where('status_transaksi', 'diterima')->sum('total_bayar') + + // BookingFoto::whereMonth('created_at', $lastMonth->month)->whereYear('created_at', $lastMonth->year)->where('status_booking', 'diterima')->sum('total_bayar'); + + // $prevMasuk = TransaksiBuket::whereMonth('created_at', $lastMonth->month)->whereYear('created_at', $lastMonth->year)->count() + + // BookingFoto::whereMonth('created_at', $lastMonth->month)->whereYear('created_at', $lastMonth->year)->count(); + + // $prevSelesai = TransaksiBuket::whereMonth('created_at', $lastMonth->month)->whereYear('created_at', $lastMonth->year)->where('status_transaksi', 'selesai')->count() + + // BookingFoto::whereMonth('created_at', $lastMonth->month)->whereYear('created_at', $lastMonth->year)->where('status_booking', 'selesai')->count(); + + // $prevBatal = TransaksiBuket::whereMonth('created_at', $lastMonth->month)->whereYear('created_at', $lastMonth->year)->where('status_transaksi', 'ditolak')->count() + + // BookingFoto::whereMonth('created_at', $lastMonth->month)->whereYear('created_at', $lastMonth->year)->where('status_booking', 'ditolak')->count(); + // $stat = [ + // 'pendapatan' => $currPendapatan, + // 'pendapatan_grow' => $getGrowth($currPendapatan, $prevPendapatan), + // 'masuk_count' => $currMasuk, + // 'masuk_grow' => $getGrowth($currMasuk, $prevMasuk), + // 'selesai_count' => $currSelesai, + // 'selesai_grow' => $getGrowth($currSelesai, $prevSelesai), + // 'batal_count' => $currBatal, + // 'batal_grow' => $getGrowth($currBatal, $prevBatal), + // ]; + // $buketToday = TransaksiBuket::with(['pelanggan', 'buket'])->whereDate('tgl_ambil', $today)->where('status_transaksi', 'diterima')->get(); + // $fotoToday = BookingFoto::with(['pelanggan', 'paketFoto'])->whereDate('tgl_booking', $today)->where('status_booking', 'diterima')->orderBy('jam_mulai', 'asc')->get(); + // $pesananBuket = TransaksiBuket::with(['pelanggan', 'buket'])->where('status_transaksi', 'menunggu_verifikasi')->latest()->get(); + // $pesananFoto = BookingFoto::with(['pelanggan', 'paketFoto'])->where('status_booking', 'menunggu_verifikasi')->latest()->get(); + + // return view('admin.beranda.index', compact('stat', 'buketToday', 'fotoToday', 'pesananBuket', 'pesananFoto')); + // } } diff --git a/app/Http/Requests/Admin/ProfilRequest.php b/app/Http/Requests/Admin/ProfilRequest.php new file mode 100644 index 0000000..fd9f023 --- /dev/null +++ b/app/Http/Requests/Admin/ProfilRequest.php @@ -0,0 +1,28 @@ +|string> + */ + public function rules(): array + { + return [ + // + ]; + } +}