refactor: update payroll generation to exclude Developer and Owner roles using the new withoutSuperAdmin scope.

This commit is contained in:
Yoga Pangestu 2026-02-10 12:00:19 +07:00
parent c2bcb3d47b
commit e89cfd337a
2 changed files with 9 additions and 1 deletions

View File

@ -24,7 +24,7 @@ public function handle(): void
$users = User::whereHas('employee')
->active()
->withoutDeveloper()
->withoutSuperAdmin()
->with('employee')
->get();

View File

@ -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');