improved default scopes

This commit is contained in:
Denis Duliçi
2022-06-10 19:26:32 +03:00
parent 5890a99bf9
commit 92065bd49d
13 changed files with 68 additions and 79 deletions

View File

@ -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()

View File

@ -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()

View File

@ -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')]);
}
/**