mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-28 09:51:21 -06:00
First attempt at scopeExpanded(), included some new fields in QUERYFIELDS.
This commit is contained in:
parent
b00c7b0ce3
commit
b317d1a171
@ -50,22 +50,23 @@ class TransactionJournal extends Model
|
||||
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 */
|
||||
protected $dates = ['created_at', 'updated_at', 'date', 'deleted_at', 'interest_date', 'book_date'];
|
||||
|
||||
/** @var array */
|
||||
protected $fillable
|
||||
= ['user_id', 'transaction_type_id', 'bill_id',
|
||||
'transaction_currency_id', 'description', 'completed',
|
||||
'date', 'rent_date', 'book_date', 'encrypted', 'tag_count'];
|
||||
|
||||
/** @var array */
|
||||
protected $hidden = ['encrypted'];
|
||||
|
||||
/** @var array */
|
||||
protected $rules
|
||||
= [
|
||||
@ -270,6 +271,18 @@ class TransactionJournal extends Model
|
||||
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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user