feat(user): menambahkan scope untuk mengecualikan developer dan menuliskannya di kueri analisa

This commit is contained in:
Yoga Pangestu 2025-11-12 20:02:23 +07:00
parent 063342841b
commit 96c2461b7c
2 changed files with 14 additions and 0 deletions

View File

@ -108,6 +108,7 @@ protected function loadData()
'value' => User::whereHas('employee')
->when(! empty($outletIds), fn ($q) => $q->whereHas('outlets', fn ($q2) => $q2->whereIn('outlets.id', $outletIds)))
->when($dateQuery || ($startDate && $endDate), $filterDate)
->withoutDeveloper()
->count(),
],
[

View File

@ -49,6 +49,14 @@ protected function active(Builder $query): void
$query->where('status', UserStatus::ACTIVE);
}
#[Scope]
protected function withoutDeveloper(Builder $query): void
{
$query->whereDoesntHave('roles', function ($q) {
$q->where('name', 'Developer');
});
}
public function employee(): HasOne
{
return $this->hasOne(Employee::class);
@ -118,4 +126,9 @@ public function vouchers(): BelongsToMany
{
return $this->belongsToMany(Voucher::class);
}
public function pointRecords(): HasMany
{
return $this->hasMany(PointRecord::class);
}
}