added recurring scope to document models

This commit is contained in:
Cihan Şentürk
2023-07-20 15:44:03 +03:00
committed by GitHub
parent 10a39de970
commit a6a13481fe
4 changed files with 64 additions and 0 deletions

View File

@ -30,8 +30,24 @@ class DocumentHistory extends Model
return $query->where($this->qualifyColumn('type'), '=', Document::INVOICE_TYPE);
}
public function scopeInvoiceRecurring(Builder $query): Builder
{
return $query->where($this->qualifyColumn('type'), '=', Document::INVOICE_RECURRING_TYPE)
->whereHas('document.recurring', function (Builder $query) {
$query->whereNull('deleted_at');
});
}
public function scopeBill(Builder $query)
{
return $query->where($this->qualifyColumn('type'), '=', Document::BILL_TYPE);
}
public function scopeBillRecurring(Builder $query): Builder
{
return $query->where($this->qualifyColumn('type'), '=', Document::BILL_RECURRING_TYPE)
->whereHas('document.recurring', function (Builder $query) {
$query->whereNull('deleted_at');
});
}
}