feat(payroll): membuat scope paid dan menerapkan nya di analisa
This commit is contained in:
parent
adb8676ac3
commit
8b700bd388
@ -264,6 +264,7 @@ protected function loadData()
|
||||
'value' => currency(
|
||||
Payroll::when(! empty($outletIds), fn ($q) => $q->whereHas('user.outlets', fn ($q2) => $q2->whereIn('outlets.id', $outletIds)))
|
||||
->when($dateQuery || ($startDate && $endDate), $filterDate)
|
||||
->paid()
|
||||
->sum('total_salary'),
|
||||
'Rp'
|
||||
),
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
|
||||
use App\Enums\IsPaid;
|
||||
use Dyrynda\Database\Support\CascadeSoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Attributes\Scope;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@ -30,6 +32,12 @@ protected function casts(): array
|
||||
];
|
||||
}
|
||||
|
||||
#[Scope]
|
||||
public function paid(Builder $query): void
|
||||
{
|
||||
$query->where('is_paid', IsPaid::PAID->value);
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user