mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-23 14:26:58 +00:00
First attempt at scopeExpanded(), included some new fields in QUERYFIELDS.
This commit is contained in:
@@ -50,22 +50,23 @@ class TransactionJournal extends Model
|
|||||||
use SoftDeletes, ValidatingTrait;
|
use SoftDeletes, ValidatingTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fields which queries must load..
|
* Fields which queries must load.
|
||||||
|
* ['transaction_journals.*', 'transaction_currencies.symbol', 'transaction_types.type']
|
||||||
*/
|
*/
|
||||||
const QUERYFIELDS = ['transaction_journals.*'];
|
const QUERYFIELDS
|
||||||
|
= [
|
||||||
|
'transaction_journals.*',
|
||||||
|
'transaction_types.type as transaction_type_type', // the other field is called "transaction_type_id" so this is pretty consistent.
|
||||||
|
];
|
||||||
/** @var array */
|
/** @var array */
|
||||||
protected $dates = ['created_at', 'updated_at', 'date', 'deleted_at', 'interest_date', 'book_date'];
|
protected $dates = ['created_at', 'updated_at', 'date', 'deleted_at', 'interest_date', 'book_date'];
|
||||||
|
|
||||||
/** @var array */
|
/** @var array */
|
||||||
protected $fillable
|
protected $fillable
|
||||||
= ['user_id', 'transaction_type_id', 'bill_id',
|
= ['user_id', 'transaction_type_id', 'bill_id',
|
||||||
'transaction_currency_id', 'description', 'completed',
|
'transaction_currency_id', 'description', 'completed',
|
||||||
'date', 'rent_date', 'book_date', 'encrypted', 'tag_count'];
|
'date', 'rent_date', 'book_date', 'encrypted', 'tag_count'];
|
||||||
|
|
||||||
/** @var array */
|
/** @var array */
|
||||||
protected $hidden = ['encrypted'];
|
protected $hidden = ['encrypted'];
|
||||||
|
|
||||||
/** @var array */
|
/** @var array */
|
||||||
protected $rules
|
protected $rules
|
||||||
= [
|
= [
|
||||||
@@ -270,6 +271,18 @@ class TransactionJournal extends Model
|
|||||||
return $query->where('transaction_journals.date', '<=', $date->format('Y-m-d 00:00:00'));
|
return $query->where('transaction_journals.date', '<=', $date->format('Y-m-d 00:00:00'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param EloquentBuilder $query
|
||||||
|
*/
|
||||||
|
public function scopeExpanded(EloquentBuilder $query)
|
||||||
|
{
|
||||||
|
// left join transaction type:
|
||||||
|
$query->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id');
|
||||||
|
|
||||||
|
// try to get amount
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user