Skip to content

Commit

Permalink
Recurring model document scopes updated
Browse files Browse the repository at this point in the history
  • Loading branch information
CihanSenturk committed Feb 1, 2024
1 parent 5c924f1 commit 67bad76
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/Models/Common/Recurring.php
Expand Up @@ -129,15 +129,17 @@ public function scopeInvoice(Builder $query): Builder
return $query->where($this->qualifyColumn('recurable_type'), '=', 'App\\Models\\Document\\Document')
->whereHas('recurable', function (Builder $query) {
$query->where('type', self::INVOICE_RECURRING_TYPE);
});
})
->orWhereDoesntHave('recurable');
}

public function scopeBill(Builder $query): Builder
{
return $query->where($this->qualifyColumn('recurable_type'), '=', 'App\\Models\\Document\\Document')
->whereHas('recurable', function (Builder $query) {
$query->where('type', self::BILL_RECURRING_TYPE);
});
})
->orWhereDoesntHave('recurable');
}

public function scopeTransaction(Builder $query): Builder
Expand All @@ -150,15 +152,17 @@ public function scopeExpenseTransaction(Builder $query): Builder
return $query->where($this->qualifyColumn('recurable_type'), '=', 'App\\Models\\Banking\\Transaction')
->whereHas('recurable', function (Builder $query) {
$query->where('type', self::EXPENSE_RECURRING_TYPE);
});
})
->orWhereDoesntHave('recurable');
}

public function scopeIncomeTransaction(Builder $query): Builder
{
return $query->where($this->qualifyColumn('recurable_type'), '=', 'App\\Models\\Banking\\Transaction')
->whereHas('recurable', function (Builder $query) {
$query->where('type', self::INCOME_RECURRING_TYPE);
});
})
->orWhereDoesntHave('recurable');
}

/**
Expand Down

0 comments on commit 67bad76

Please sign in to comment.