mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
New model for future implementation of #164
This commit is contained in:
@@ -56,6 +56,7 @@ use Watson\Validating\ValidatingTrait;
|
||||
* @property string $type
|
||||
* @property \Carbon\Carbon $interest_date
|
||||
* @property \Carbon\Carbon $book_date
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournalMeta[] $transactionjournalmeta
|
||||
*/
|
||||
class TransactionJournal extends Model
|
||||
{
|
||||
@@ -85,6 +86,24 @@ class TransactionJournal extends Model
|
||||
/** @var bool */
|
||||
private $joinedTransactionTypes;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $fieldName
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMeta($fieldName): string
|
||||
{
|
||||
foreach ($this->transactionjournalmeta as $meta) {
|
||||
if ($meta->name == $fieldName) {
|
||||
return $meta->data;
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*
|
||||
@@ -404,6 +423,14 @@ class TransactionJournal extends Model
|
||||
return $this->belongsToMany('FireflyIII\Models\TransactionGroup');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function transactionjournalmeta(): HasMany
|
||||
{
|
||||
return $this->hasMany('FireflyIII\Models\TransactionJournalMeta');
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
|
Reference in New Issue
Block a user