From e89cfd337a783b797d489c215ebd1fd13006986e Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Tue, 10 Feb 2026 12:00:19 +0700 Subject: [PATCH] refactor: update payroll generation to exclude Developer and Owner roles using the new `withoutSuperAdmin` scope. --- app/Console/Commands/GeneratePayrolls.php | 2 +- app/Models/User.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Console/Commands/GeneratePayrolls.php b/app/Console/Commands/GeneratePayrolls.php index 0c85ccf..2fcfbf1 100644 --- a/app/Console/Commands/GeneratePayrolls.php +++ b/app/Console/Commands/GeneratePayrolls.php @@ -24,7 +24,7 @@ public function handle(): void $users = User::whereHas('employee') ->active() - ->withoutDeveloper() + ->withoutSuperAdmin() ->with('employee') ->get(); diff --git a/app/Models/User.php b/app/Models/User.php index ba12836..fdc46da 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -60,6 +60,14 @@ protected function withoutDeveloper(Builder $query): void }); } + #[Scope] + protected function withoutSuperAdmin(Builder $query): void + { + $query->whereDoesntHave('roles', function ($q) { + $q->whereIn('name', ['Developer', 'Owner']); + }); + } + public function articles(): HasMany { return $this->hasMany(Article::class, 'author_id');