feat(user): menambahkan scope untuk mengecualikan developer dan menuliskannya di kueri analisa
This commit is contained in:
parent
063342841b
commit
96c2461b7c
@ -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(),
|
||||
],
|
||||
[
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user