improved default scopes
This commit is contained in:
@ -51,12 +51,12 @@ class Account extends Model
|
||||
|
||||
public function expense_transactions()
|
||||
{
|
||||
return $this->transactions()->whereIn('type', (array) $this->getExpenseTypes());
|
||||
return $this->transactions()->whereIn('transactions.type', (array) $this->getExpenseTypes());
|
||||
}
|
||||
|
||||
public function income_transactions()
|
||||
{
|
||||
return $this->transactions()->whereIn('type', (array) $this->getIncomeTypes());
|
||||
return $this->transactions()->whereIn('transactions.type', (array) $this->getIncomeTypes());
|
||||
}
|
||||
|
||||
public function transactions()
|
||||
|
@ -98,7 +98,7 @@ class Transaction extends Model
|
||||
|
||||
public function bill()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Document\Document', 'document_id');
|
||||
return $this->belongsTo('App\Models\Document\Document', 'document_id')->withoutGlobalScope('App\Scopes\Document');
|
||||
}
|
||||
|
||||
public function category()
|
||||
@ -123,12 +123,12 @@ class Transaction extends Model
|
||||
|
||||
public function invoice()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Document\Document', 'document_id');
|
||||
return $this->belongsTo('App\Models\Document\Document', 'document_id')->withoutGlobalScope('App\Scopes\Document');
|
||||
}
|
||||
|
||||
public function document()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Document\Document', 'document_id');
|
||||
return $this->belongsTo('App\Models\Document\Document', 'document_id')->withoutGlobalScope('App\Scopes\Document');
|
||||
}
|
||||
|
||||
public function parent()
|
||||
|
@ -54,34 +54,42 @@ class Transfer extends Model
|
||||
|
||||
public function expense_transaction()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Banking\Transaction', 'expense_transaction_id')->withDefault(['name' => trans('general.na')]);
|
||||
return $this->belongsTo('App\Models\Banking\Transaction', 'expense_transaction_id')
|
||||
->withoutGlobalScope('App\Scopes\Transaction')
|
||||
->withDefault(['name' => trans('general.na')]);
|
||||
}
|
||||
|
||||
public function expense_account()
|
||||
{
|
||||
return $this->belongsToThrough(
|
||||
'App\Models\Banking\Account',
|
||||
'App\Models\Banking\Transaction',
|
||||
null,
|
||||
'',
|
||||
['App\Models\Banking\Transaction' => 'expense_transaction_id']
|
||||
)->withDefault(['name' => trans('general.na')]);
|
||||
'App\Models\Banking\Account',
|
||||
'App\Models\Banking\Transaction',
|
||||
null,
|
||||
'',
|
||||
['App\Models\Banking\Transaction' => 'expense_transaction_id']
|
||||
)
|
||||
->withoutGlobalScope('App\Scopes\Transaction')
|
||||
->withDefault(['name' => trans('general.na')]);
|
||||
}
|
||||
|
||||
public function income_transaction()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Banking\Transaction', 'income_transaction_id')->withDefault(['name' => trans('general.na')]);
|
||||
return $this->belongsTo('App\Models\Banking\Transaction', 'income_transaction_id')
|
||||
->withoutGlobalScope('App\Scopes\Transaction')
|
||||
->withDefault(['name' => trans('general.na')]);
|
||||
}
|
||||
|
||||
public function income_account()
|
||||
{
|
||||
return $this->belongsToThrough(
|
||||
'App\Models\Banking\Account',
|
||||
'App\Models\Banking\Transaction',
|
||||
null,
|
||||
'',
|
||||
['App\Models\Banking\Transaction' => 'income_transaction_id']
|
||||
)->withDefault(['name' => trans('general.na')]);
|
||||
'App\Models\Banking\Account',
|
||||
'App\Models\Banking\Transaction',
|
||||
null,
|
||||
'',
|
||||
['App\Models\Banking\Transaction' => 'income_transaction_id']
|
||||
)
|
||||
->withoutGlobalScope('App\Scopes\Transaction')
|
||||
->withDefault(['name' => trans('general.na')]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,7 +94,7 @@ class Contact extends Model
|
||||
|
||||
public function bills()
|
||||
{
|
||||
return $this->documents()->where('type', Document::BILL_TYPE);
|
||||
return $this->documents()->where('documents.type', Document::BILL_TYPE);
|
||||
}
|
||||
|
||||
public function currency()
|
||||
@ -104,17 +104,17 @@ class Contact extends Model
|
||||
|
||||
public function expense_transactions()
|
||||
{
|
||||
return $this->transactions()->whereIn('type', (array) $this->getExpenseTypes());
|
||||
return $this->transactions()->whereIn('transactions.type', (array) $this->getExpenseTypes());
|
||||
}
|
||||
|
||||
public function income_transactions()
|
||||
{
|
||||
return $this->transactions()->whereIn('type', (array) $this->getIncomeTypes());
|
||||
return $this->transactions()->whereIn('transactions.type', (array) $this->getIncomeTypes());
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
{
|
||||
return $this->documents()->where('type', Document::INVOICE_TYPE);
|
||||
return $this->documents()->where('documents.type', Document::INVOICE_TYPE);
|
||||
}
|
||||
|
||||
public function transactions()
|
||||
|
@ -17,7 +17,7 @@ class DocumentHistory extends Model
|
||||
|
||||
public function document()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Document\Document');
|
||||
return $this->belongsTo('App\Models\Document\Document')->withoutGlobalScope('App\Scopes\Document');
|
||||
}
|
||||
|
||||
public function scopeType(Builder $query, string $type)
|
||||
|
@ -69,7 +69,7 @@ class DocumentItem extends Model
|
||||
|
||||
public function document()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Document\Document');
|
||||
return $this->belongsTo('App\Models\Document\Document')->withoutGlobalScope('App\Scopes\Document');
|
||||
}
|
||||
|
||||
public function item()
|
||||
|
@ -26,7 +26,7 @@ class DocumentItemTax extends Model
|
||||
|
||||
public function document()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Document\Document');
|
||||
return $this->belongsTo('App\Models\Document\Document')->withoutGlobalScope('App\Scopes\Document');
|
||||
}
|
||||
|
||||
public function item()
|
||||
|
@ -29,7 +29,7 @@ class DocumentTotal extends Model
|
||||
|
||||
public function document()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Document\Document');
|
||||
return $this->belongsTo('App\Models\Document\Document')->withoutGlobalScope('App\Scopes\Document');
|
||||
}
|
||||
|
||||
public function scopeType(Builder $query, string $type)
|
||||
|
@ -112,22 +112,22 @@ class Category extends Model
|
||||
|
||||
public function bills()
|
||||
{
|
||||
return $this->documents()->where('type', Document::BILL_TYPE);
|
||||
return $this->documents()->where('documents.type', Document::BILL_TYPE);
|
||||
}
|
||||
|
||||
public function expense_transactions()
|
||||
{
|
||||
return $this->transactions()->whereIn('type', (array) $this->getExpenseTypes());
|
||||
return $this->transactions()->whereIn('transactions.type', (array) $this->getExpenseTypes());
|
||||
}
|
||||
|
||||
public function income_transactions()
|
||||
{
|
||||
return $this->transactions()->whereIn('type', (array) $this->getIncomeTypes());
|
||||
return $this->transactions()->whereIn('transactions.type', (array) $this->getIncomeTypes());
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
{
|
||||
return $this->documents()->where('type', Document::INVOICE_TYPE);
|
||||
return $this->documents()->where('documents.type', Document::INVOICE_TYPE);
|
||||
}
|
||||
|
||||
public function items()
|
||||
|
@ -63,7 +63,7 @@ class Currency extends Model
|
||||
|
||||
public function bills()
|
||||
{
|
||||
return $this->documents()->where('type', Document::BILL_TYPE);
|
||||
return $this->documents()->where('documents.type', Document::BILL_TYPE);
|
||||
}
|
||||
|
||||
public function contacts()
|
||||
@ -73,22 +73,22 @@ class Currency extends Model
|
||||
|
||||
public function customers()
|
||||
{
|
||||
return $this->contacts()->whereIn('type', (array) $this->getCustomerTypes());
|
||||
return $this->contacts()->whereIn('contacts.type', (array) $this->getCustomerTypes());
|
||||
}
|
||||
|
||||
public function expense_transactions()
|
||||
{
|
||||
return $this->transactions()->whereIn('type', (array) $this->getExpenseTypes());
|
||||
return $this->transactions()->whereIn('transactions.type', (array) $this->getExpenseTypes());
|
||||
}
|
||||
|
||||
public function income_transactions()
|
||||
{
|
||||
return $this->transactions()->whereIn('type', (array) $this->getIncomeTypes());
|
||||
return $this->transactions()->whereIn('transactions.type', (array) $this->getIncomeTypes());
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
{
|
||||
return $this->documents()->where('type', Document::INVOICE_TYPE);
|
||||
return $this->documents()->where('documents.type', Document::INVOICE_TYPE);
|
||||
}
|
||||
|
||||
public function transactions()
|
||||
@ -98,7 +98,7 @@ class Currency extends Model
|
||||
|
||||
public function vendors()
|
||||
{
|
||||
return $this->contacts()->whereIn('type', (array) $this->getVendorTypes());
|
||||
return $this->contacts()->whereIn('contacts.type', (array) $this->getVendorTypes());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,12 +55,12 @@ class Tax extends Model
|
||||
|
||||
public function bill_items()
|
||||
{
|
||||
return $this->document_items()->where('type', Document::BILL_TYPE);
|
||||
return $this->document_items()->where('documents.type', Document::BILL_TYPE);
|
||||
}
|
||||
|
||||
public function invoice_items()
|
||||
{
|
||||
return $this->document_items()->where('type', Document::INVOICE_TYPE);
|
||||
return $this->document_items()->where('documents.type', Document::INVOICE_TYPE);
|
||||
}
|
||||
|
||||
public function scopeName($query, $name)
|
||||
|
Reference in New Issue
Block a user