fix tests
This commit is contained in:
@@ -16,7 +16,7 @@ class RefundQueryService
|
||||
$sortDir = strtolower((string) ($filters['sort_dir'] ?? 'desc')) === 'asc' ? 'asc' : 'desc';
|
||||
|
||||
$allowedSorts = ['created_at', 'updated_at', 'refund_amount', 'status', 'parent_id', 'invoice_id'];
|
||||
if (!in_array($sortBy, $allowedSorts, true)) {
|
||||
if (! in_array($sortBy, $allowedSorts, true)) {
|
||||
$sortBy = 'created_at';
|
||||
}
|
||||
|
||||
@@ -29,25 +29,25 @@ class RefundQueryService
|
||||
->leftJoin('users as parents', 'parents.id', '=', 'refunds.parent_id')
|
||||
->leftJoin('users as approvers', 'approvers.id', '=', 'refunds.approved_by');
|
||||
|
||||
if (!empty($filters['status'])) {
|
||||
if (! empty($filters['status'])) {
|
||||
$query->where('refunds.status', $filters['status']);
|
||||
}
|
||||
if (!empty($filters['request'])) {
|
||||
if (! empty($filters['request'])) {
|
||||
$query->where('refunds.request', $filters['request']);
|
||||
}
|
||||
if (!empty($filters['parent_id'])) {
|
||||
if (! empty($filters['parent_id'])) {
|
||||
$query->where('refunds.parent_id', (int) $filters['parent_id']);
|
||||
}
|
||||
if (!empty($filters['invoice_id'])) {
|
||||
if (! empty($filters['invoice_id'])) {
|
||||
$query->where('refunds.invoice_id', (int) $filters['invoice_id']);
|
||||
}
|
||||
if (!empty($filters['school_year'])) {
|
||||
if (! empty($filters['school_year'])) {
|
||||
$query->where('refunds.school_year', (string) $filters['school_year']);
|
||||
}
|
||||
if (!empty($filters['semester'])) {
|
||||
if (! empty($filters['semester'])) {
|
||||
$query->where('refunds.semester', (string) $filters['semester']);
|
||||
}
|
||||
if (!empty($filters['q'])) {
|
||||
if (! empty($filters['q'])) {
|
||||
$term = trim((string) $filters['q']);
|
||||
$query->where(function ($where) use ($term) {
|
||||
$where->where('refunds.reason', 'like', "%{$term}%")
|
||||
@@ -57,7 +57,7 @@ class RefundQueryService
|
||||
});
|
||||
}
|
||||
|
||||
$paginator = $query->orderBy('refunds.' . $sortBy, $sortDir)
|
||||
$paginator = $query->orderBy('refunds.'.$sortBy, $sortDir)
|
||||
->paginate($perPage, ['*'], 'page', $page);
|
||||
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user