diff --git a/app/Http/Controllers/Admin/Dashboard/OverviewController.php b/app/Http/Controllers/Admin/Dashboard/OverviewController.php index afcadad..09b0307 100644 --- a/app/Http/Controllers/Admin/Dashboard/OverviewController.php +++ b/app/Http/Controllers/Admin/Dashboard/OverviewController.php @@ -54,6 +54,9 @@ public function index() $todayNewCustomer = Transaction::with('customer')->whereDoesntHave('customer.transactions', function ($query) { $query->where('id', '<>', DB::raw('transactions.id')); }) + ->when(auth()->user()->role_id === 5, function ($query) { + return $query->where('user_id', auth()->id()); + }) ->barbershop() ->today() ->distinct('customer_id') @@ -62,6 +65,9 @@ public function index() $yesterdayNewCustomer = Transaction::with('customer')->whereDoesntHave('customer.transactions', function ($query) { $query->where('id', '<>', DB::raw('transactions.id')); }) + ->when(auth()->user()->role_id === 5, function ($query) { + return $query->where('user_id', auth()->id()); + }) ->barbershop() ->yesterday() ->distinct('customer_id') @@ -84,8 +90,12 @@ public function index() ->barbershop() ->barber() ->withSum('transactions', 'total') - ->withCount('transactions') - ->get(); + ->withCount('transactions'); + if (in_array(auth()->user()->role_id, [1, 2, 3])) { + $incomeByBarber = $incomeByBarber->get(); + } elseif (auth()->user()->role_id === 5) { + $incomeByBarber = $incomeByBarber->find(auth()->id()); + } return view('pages.admin.dashboard.overview', [ 'pageTitle' => 'Ringkasan', diff --git a/resources/views/pages/admin/dashboard/overview.blade.php b/resources/views/pages/admin/dashboard/overview.blade.php index 3c62b44..7c70ddc 100644 --- a/resources/views/pages/admin/dashboard/overview.blade.php +++ b/resources/views/pages/admin/dashboard/overview.blade.php @@ -144,35 +144,64 @@ -