2016-05-20 01:57:45 -05:00
|
|
|
<?php
|
2016-05-20 05:41:23 -05:00
|
|
|
/**
|
|
|
|
* TransactionJournal.php
|
2017-10-21 01:40:00 -05:00
|
|
|
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
2016-05-20 05:41:23 -05:00
|
|
|
*
|
2017-10-21 01:40:00 -05:00
|
|
|
* This file is part of Firefly III.
|
2016-10-04 23:52:15 -05:00
|
|
|
*
|
2017-10-21 01:40:00 -05:00
|
|
|
* Firefly III is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Firefly III is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2017-12-17 07:44:05 -06:00
|
|
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
2016-05-20 05:41:23 -05:00
|
|
|
*/
|
2017-04-09 00:44:22 -05:00
|
|
|
declare(strict_types=1);
|
2016-05-20 01:57:45 -05:00
|
|
|
|
|
|
|
namespace FireflyIII\Models;
|
2015-02-05 21:52:16 -06:00
|
|
|
|
2015-02-07 01:23:44 -06:00
|
|
|
use Carbon\Carbon;
|
2015-02-06 23:49:24 -06:00
|
|
|
use Crypt;
|
2016-09-09 04:19:40 -05:00
|
|
|
use FireflyIII\Support\CacheProperties;
|
2017-03-04 00:18:35 -06:00
|
|
|
use FireflyIII\Support\Models\TransactionJournalTrait;
|
2015-02-07 01:23:44 -06:00
|
|
|
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
2017-03-04 00:18:35 -06:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2017-06-05 04:12:50 -05:00
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
2015-02-22 01:38:46 -06:00
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
2015-02-07 16:19:28 -06:00
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
2016-09-09 04:19:40 -05:00
|
|
|
use Log;
|
|
|
|
use Preferences;
|
2016-01-09 08:53:11 -06:00
|
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
2016-01-18 06:15:11 -06:00
|
|
|
use Watson\Validating\ValidatingTrait;
|
2015-02-07 01:23:44 -06:00
|
|
|
|
2016-11-18 13:06:08 -06:00
|
|
|
/**
|
2017-11-15 05:25:49 -06:00
|
|
|
* Class TransactionJournal.
|
2016-11-18 13:06:08 -06:00
|
|
|
*/
|
2017-03-04 00:18:35 -06:00
|
|
|
class TransactionJournal extends Model
|
2015-02-05 22:04:06 -06:00
|
|
|
{
|
2017-03-04 00:18:35 -06:00
|
|
|
use SoftDeletes, ValidatingTrait, TransactionJournalTrait;
|
2015-02-09 00:56:24 -06:00
|
|
|
|
2016-12-24 10:36:51 -06:00
|
|
|
/**
|
|
|
|
* The attributes that should be casted to native types.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $casts
|
|
|
|
= [
|
2017-11-03 10:04:17 -05:00
|
|
|
'created_at' => 'datetime',
|
|
|
|
'updated_at' => 'datetime',
|
|
|
|
'deleted_at' => 'datetime',
|
2016-12-24 10:36:51 -06:00
|
|
|
'date' => 'date',
|
|
|
|
'interest_date' => 'date',
|
|
|
|
'book_date' => 'date',
|
|
|
|
'process_date' => 'date',
|
|
|
|
'order' => 'int',
|
|
|
|
'tag_count' => 'int',
|
|
|
|
'encrypted' => 'boolean',
|
|
|
|
'completed' => 'boolean',
|
|
|
|
];
|
2016-01-27 12:35:00 -06:00
|
|
|
/** @var array */
|
2017-11-05 12:49:20 -06:00
|
|
|
protected $dates = ['date', 'interest_date', 'book_date', 'process_date'];
|
2016-01-27 12:35:00 -06:00
|
|
|
/** @var array */
|
2015-06-14 04:52:07 -05:00
|
|
|
protected $fillable
|
2016-03-12 00:37:13 -06:00
|
|
|
= ['user_id', 'transaction_type_id', 'bill_id', 'interest_date', 'book_date', 'process_date',
|
2016-03-02 04:50:37 -06:00
|
|
|
'transaction_currency_id', 'description', 'completed',
|
2017-11-15 05:25:49 -06:00
|
|
|
'date', 'rent_date', 'encrypted', 'tag_count',];
|
2016-01-27 12:35:00 -06:00
|
|
|
/** @var array */
|
2015-06-14 04:52:07 -05:00
|
|
|
protected $hidden = ['encrypted'];
|
2016-01-27 12:35:00 -06:00
|
|
|
/** @var array */
|
2016-01-18 06:15:11 -06:00
|
|
|
protected $rules
|
2016-01-27 12:35:00 -06:00
|
|
|
= [
|
2017-06-05 04:12:50 -05:00
|
|
|
'user_id' => 'required|exists:users,id',
|
|
|
|
'transaction_type_id' => 'required|exists:transaction_types,id',
|
|
|
|
'description' => 'required|between:1,1024',
|
|
|
|
'completed' => 'required|boolean',
|
|
|
|
'date' => 'required|date',
|
|
|
|
'encrypted' => 'required|boolean',
|
2016-01-18 06:15:11 -06:00
|
|
|
];
|
2015-02-05 21:52:16 -06:00
|
|
|
|
2016-01-27 11:31:44 -06:00
|
|
|
/**
|
|
|
|
* @param $value
|
|
|
|
*
|
|
|
|
* @return mixed
|
2017-11-15 05:25:49 -06:00
|
|
|
*
|
2016-01-27 11:31:44 -06:00
|
|
|
* @throws NotFoundHttpException
|
|
|
|
*/
|
|
|
|
public static function routeBinder($value)
|
|
|
|
{
|
2016-09-16 05:07:45 -05:00
|
|
|
if (auth()->check()) {
|
2016-12-15 14:35:33 -06:00
|
|
|
$object = self::where('transaction_journals.id', $value)
|
2016-12-24 10:36:51 -06:00
|
|
|
->with('transactionType')
|
|
|
|
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
|
|
|
->where('user_id', auth()->user()->id)->first(['transaction_journals.*']);
|
2017-11-15 05:25:49 -06:00
|
|
|
if (null !== $object) {
|
2016-01-27 11:31:44 -06:00
|
|
|
return $object;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new NotFoundHttpException;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
|
|
|
|
*/
|
|
|
|
public function attachments()
|
|
|
|
{
|
|
|
|
return $this->morphMany('FireflyIII\Models\Attachment', 'attachable');
|
|
|
|
}
|
|
|
|
|
2015-02-11 00:35:10 -06:00
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
*/
|
2015-02-05 22:14:27 -06:00
|
|
|
public function bill()
|
|
|
|
{
|
2015-02-05 22:35:00 -06:00
|
|
|
return $this->belongsTo('FireflyIII\Models\Bill');
|
2015-02-05 22:14:27 -06:00
|
|
|
}
|
|
|
|
|
2015-02-11 00:35:10 -06:00
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
|
|
*/
|
2017-06-05 04:12:50 -05:00
|
|
|
public function budgets(): BelongsToMany
|
2015-02-05 22:14:27 -06:00
|
|
|
{
|
2015-02-05 22:35:00 -06:00
|
|
|
return $this->belongsToMany('FireflyIII\Models\Budget');
|
2015-02-05 22:14:27 -06:00
|
|
|
}
|
|
|
|
|
2015-02-11 00:35:10 -06:00
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
|
|
*/
|
2017-06-05 04:12:50 -05:00
|
|
|
public function categories(): BelongsToMany
|
2015-02-05 22:14:27 -06:00
|
|
|
{
|
2015-02-05 22:35:00 -06:00
|
|
|
return $this->belongsToMany('FireflyIII\Models\Category');
|
2015-02-05 22:14:27 -06:00
|
|
|
}
|
|
|
|
|
2016-09-09 04:19:40 -05:00
|
|
|
/**
|
|
|
|
* @param string $name
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2016-12-14 11:59:12 -06:00
|
|
|
public function deleteMeta(string $name): bool
|
2016-09-09 04:19:40 -05:00
|
|
|
{
|
|
|
|
$this->transactionJournalMeta()->where('name', $name)->delete();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-09-08 23:41:45 -05:00
|
|
|
/**
|
|
|
|
* @return HasMany
|
|
|
|
*/
|
|
|
|
public function destinationJournalLinks(): HasMany
|
|
|
|
{
|
|
|
|
return $this->hasMany(TransactionJournalLink::class, 'destination_id');
|
|
|
|
}
|
|
|
|
|
2015-02-11 00:35:10 -06:00
|
|
|
/**
|
|
|
|
* @param $value
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2015-02-05 22:14:27 -06:00
|
|
|
public function getDescriptionAttribute($value)
|
|
|
|
{
|
|
|
|
if ($this->encrypted) {
|
|
|
|
return Crypt::decrypt($value);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $value;
|
|
|
|
}
|
2016-03-02 04:56:47 -06:00
|
|
|
|
2016-03-02 04:50:37 -06:00
|
|
|
/**
|
2016-09-09 04:19:40 -05:00
|
|
|
* @param string $name
|
2016-03-02 04:50:37 -06:00
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2016-09-09 04:19:40 -05:00
|
|
|
public function getMeta(string $name)
|
2016-03-02 04:50:37 -06:00
|
|
|
{
|
2016-09-09 04:19:40 -05:00
|
|
|
$value = null;
|
|
|
|
$cache = new CacheProperties;
|
|
|
|
$cache->addProperty('journal-meta');
|
|
|
|
$cache->addProperty($this->id);
|
|
|
|
$cache->addProperty($name);
|
|
|
|
|
|
|
|
if ($cache->has()) {
|
2017-03-04 04:19:44 -06:00
|
|
|
return $cache->get(); // @codeCoverageIgnore
|
2016-09-09 04:19:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Log::debug(sprintf('Looking for journal #%d meta field "%s".', $this->id, $name));
|
|
|
|
$entry = $this->transactionJournalMeta()->where('name', $name)->first();
|
2017-11-15 05:25:49 -06:00
|
|
|
if (null !== $entry) {
|
2016-09-09 04:19:40 -05:00
|
|
|
$value = $entry->data;
|
|
|
|
// cache:
|
|
|
|
$cache->store($value);
|
2016-03-02 04:50:37 -06:00
|
|
|
}
|
|
|
|
|
2016-09-09 04:19:40 -05:00
|
|
|
// convert to Carbon if name is _date
|
2017-11-15 05:25:49 -06:00
|
|
|
if (null !== $value && '_date' === substr($name, -5)) {
|
2016-09-09 04:19:40 -05:00
|
|
|
$value = new Carbon($value);
|
|
|
|
// cache:
|
|
|
|
$cache->store($value);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $value;
|
2016-03-02 04:50:37 -06:00
|
|
|
}
|
|
|
|
|
2016-09-10 11:36:52 -05:00
|
|
|
/**
|
|
|
|
* @param string $name
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function hasMeta(string $name): bool
|
|
|
|
{
|
2017-11-15 05:25:49 -06:00
|
|
|
return null !== $this->getMeta($name);
|
2016-09-10 11:36:52 -05:00
|
|
|
}
|
|
|
|
|
2016-01-27 11:31:44 -06:00
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
2017-06-05 04:12:50 -05:00
|
|
|
public function isDeposit(): bool
|
2016-01-27 11:31:44 -06:00
|
|
|
{
|
2017-11-15 05:25:49 -06:00
|
|
|
if (null !== $this->transaction_type_type) {
|
|
|
|
return TransactionType::DEPOSIT === $this->transaction_type_type;
|
2016-01-27 11:31:44 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->transactionType->isDeposit();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
2017-06-05 04:12:50 -05:00
|
|
|
public function isOpeningBalance(): bool
|
2016-01-27 11:31:44 -06:00
|
|
|
{
|
2017-11-15 05:25:49 -06:00
|
|
|
if (null !== $this->transaction_type_type) {
|
|
|
|
return TransactionType::OPENING_BALANCE === $this->transaction_type_type;
|
2016-01-27 11:31:44 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->transactionType->isOpeningBalance();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
2017-06-05 04:12:50 -05:00
|
|
|
public function isTransfer(): bool
|
2016-01-27 11:31:44 -06:00
|
|
|
{
|
2017-11-15 05:25:49 -06:00
|
|
|
if (null !== $this->transaction_type_type) {
|
|
|
|
return TransactionType::TRANSFER === $this->transaction_type_type;
|
2016-01-27 11:31:44 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->transactionType->isTransfer();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
2017-06-05 04:12:50 -05:00
|
|
|
public function isWithdrawal(): bool
|
2016-01-27 11:31:44 -06:00
|
|
|
{
|
2017-11-15 05:25:49 -06:00
|
|
|
if (null !== $this->transaction_type_type) {
|
|
|
|
return TransactionType::WITHDRAWAL === $this->transaction_type_type;
|
2016-01-27 11:31:44 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->transactionType->isWithdrawal();
|
|
|
|
}
|
|
|
|
|
2017-10-03 03:30:56 -05:00
|
|
|
/**
|
|
|
|
* Get all of the notes.
|
|
|
|
*/
|
|
|
|
public function notes()
|
|
|
|
{
|
|
|
|
return $this->morphMany('FireflyIII\Models\Note', 'noteable');
|
|
|
|
}
|
|
|
|
|
2015-02-11 00:35:10 -06:00
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
|
|
*/
|
2017-06-05 04:12:50 -05:00
|
|
|
public function piggyBankEvents(): HasMany
|
2015-02-05 22:14:27 -06:00
|
|
|
{
|
2015-02-05 22:35:00 -06:00
|
|
|
return $this->hasMany('FireflyIII\Models\PiggyBankEvent');
|
2015-02-05 22:14:27 -06:00
|
|
|
}
|
|
|
|
|
2016-01-27 11:31:44 -06:00
|
|
|
/**
|
|
|
|
* Save the model to the database.
|
|
|
|
*
|
2017-11-15 05:25:49 -06:00
|
|
|
* @param array $options
|
2016-01-27 11:31:44 -06:00
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2017-06-05 04:12:50 -05:00
|
|
|
public function save(array $options = []): bool
|
2016-01-27 11:31:44 -06:00
|
|
|
{
|
|
|
|
$count = $this->tags()->count();
|
|
|
|
$this->tag_count = $count;
|
|
|
|
|
|
|
|
return parent::save($options);
|
|
|
|
}
|
|
|
|
|
2015-02-07 01:23:44 -06:00
|
|
|
/**
|
|
|
|
* @param EloquentBuilder $query
|
|
|
|
* @param Carbon $date
|
|
|
|
*
|
2015-05-26 13:57:31 -05:00
|
|
|
* @return EloquentBuilder
|
2015-02-07 01:23:44 -06:00
|
|
|
*/
|
|
|
|
public function scopeAfter(EloquentBuilder $query, Carbon $date)
|
|
|
|
{
|
|
|
|
return $query->where('transaction_journals.date', '>=', $date->format('Y-m-d 00:00:00'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param EloquentBuilder $query
|
|
|
|
* @param Carbon $date
|
|
|
|
*
|
2015-05-26 13:57:31 -05:00
|
|
|
* @return EloquentBuilder
|
2015-02-07 01:23:44 -06:00
|
|
|
*/
|
|
|
|
public function scopeBefore(EloquentBuilder $query, Carbon $date)
|
|
|
|
{
|
|
|
|
return $query->where('transaction_journals.date', '<=', $date->format('Y-m-d 00:00:00'));
|
|
|
|
}
|
|
|
|
|
2016-05-20 04:27:41 -05:00
|
|
|
/**
|
|
|
|
* @param EloquentBuilder $query
|
|
|
|
*/
|
|
|
|
public function scopeSortCorrectly(EloquentBuilder $query)
|
|
|
|
{
|
|
|
|
$query->orderBy('transaction_journals.date', 'DESC');
|
|
|
|
$query->orderBy('transaction_journals.order', 'ASC');
|
|
|
|
$query->orderBy('transaction_journals.id', 'DESC');
|
|
|
|
}
|
|
|
|
|
2015-02-07 01:23:44 -06:00
|
|
|
/**
|
|
|
|
* @param EloquentBuilder $query
|
|
|
|
* @param array $types
|
|
|
|
*/
|
|
|
|
public function scopeTransactionTypes(EloquentBuilder $query, array $types)
|
|
|
|
{
|
2016-03-02 05:52:36 -06:00
|
|
|
if (!self::isJoined($query, 'transaction_types')) {
|
2016-03-02 05:47:15 -06:00
|
|
|
$query->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id');
|
|
|
|
}
|
2016-11-01 12:40:35 -05:00
|
|
|
if (count($types) > 0) {
|
|
|
|
$query->whereIn('transaction_types.type', $types);
|
|
|
|
}
|
2016-05-15 11:36:40 -05:00
|
|
|
}
|
2015-02-07 01:23:44 -06:00
|
|
|
|
2015-02-11 00:35:10 -06:00
|
|
|
/**
|
|
|
|
* @param $value
|
|
|
|
*/
|
2015-02-05 22:14:27 -06:00
|
|
|
public function setDescriptionAttribute($value)
|
|
|
|
{
|
2017-01-14 10:13:57 -06:00
|
|
|
$encrypt = config('firefly.encryption');
|
|
|
|
$this->attributes['description'] = $encrypt ? Crypt::encrypt($value) : $value;
|
|
|
|
$this->attributes['encrypted'] = $encrypt;
|
2015-02-05 22:14:27 -06:00
|
|
|
}
|
|
|
|
|
2015-07-18 02:49:19 -05:00
|
|
|
/**
|
2016-09-09 04:19:40 -05:00
|
|
|
* @param string $name
|
|
|
|
* @param $value
|
|
|
|
*
|
|
|
|
* @return TransactionJournalMeta
|
2015-07-18 02:49:19 -05:00
|
|
|
*/
|
2016-09-09 04:19:40 -05:00
|
|
|
public function setMeta(string $name, $value): TransactionJournalMeta
|
2015-07-18 02:49:19 -05:00
|
|
|
{
|
2017-11-15 05:25:49 -06:00
|
|
|
if (null === $value) {
|
2016-09-09 04:19:40 -05:00
|
|
|
$this->deleteMeta($name);
|
|
|
|
|
|
|
|
return new TransactionJournalMeta();
|
|
|
|
}
|
2017-11-15 05:25:49 -06:00
|
|
|
if (is_string($value) && 0 === strlen($value)) {
|
2017-11-30 12:39:49 -06:00
|
|
|
$this->deleteMeta($name);
|
2017-11-30 12:43:02 -06:00
|
|
|
|
2016-10-21 12:06:22 -05:00
|
|
|
return new TransactionJournalMeta();
|
|
|
|
}
|
2016-09-09 04:19:40 -05:00
|
|
|
|
|
|
|
if ($value instanceof Carbon) {
|
|
|
|
$value = $value->toW3cString();
|
|
|
|
}
|
|
|
|
|
|
|
|
Log::debug(sprintf('Going to set "%s" with value "%s"', $name, json_encode($value)));
|
|
|
|
$entry = $this->transactionJournalMeta()->where('name', $name)->first();
|
2017-11-15 05:25:49 -06:00
|
|
|
if (null === $entry) {
|
2016-09-09 04:19:40 -05:00
|
|
|
$entry = new TransactionJournalMeta();
|
|
|
|
$entry->transactionJournal()->associate($this);
|
|
|
|
$entry->name = $name;
|
|
|
|
}
|
|
|
|
$entry->data = $value;
|
|
|
|
$entry->save();
|
|
|
|
Preferences::mark();
|
|
|
|
|
|
|
|
return $entry;
|
2015-07-18 02:49:19 -05:00
|
|
|
}
|
|
|
|
|
2017-08-21 00:13:03 -05:00
|
|
|
/**
|
|
|
|
* @return HasMany
|
|
|
|
*/
|
|
|
|
public function sourceJournalLinks(): HasMany
|
|
|
|
{
|
|
|
|
return $this->hasMany(TransactionJournalLink::class, 'source_id');
|
|
|
|
}
|
|
|
|
|
2015-02-11 00:35:10 -06:00
|
|
|
/**
|
2016-09-09 04:19:40 -05:00
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
2015-02-11 00:35:10 -06:00
|
|
|
*/
|
2016-09-09 04:19:40 -05:00
|
|
|
public function tags()
|
2015-02-05 22:14:27 -06:00
|
|
|
{
|
2016-09-09 04:19:40 -05:00
|
|
|
return $this->belongsToMany('FireflyIII\Models\Tag');
|
2015-02-05 22:14:27 -06:00
|
|
|
}
|
|
|
|
|
2015-02-11 00:35:10 -06:00
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
*/
|
2016-09-09 04:19:40 -05:00
|
|
|
public function transactionCurrency()
|
2015-02-05 22:14:27 -06:00
|
|
|
{
|
2016-09-09 04:19:40 -05:00
|
|
|
return $this->belongsTo('FireflyIII\Models\TransactionCurrency');
|
2015-02-05 22:14:27 -06:00
|
|
|
}
|
|
|
|
|
2015-02-11 00:35:10 -06:00
|
|
|
/**
|
2016-09-09 04:19:40 -05:00
|
|
|
* @return HasMany
|
2015-02-11 00:35:10 -06:00
|
|
|
*/
|
2016-09-09 04:19:40 -05:00
|
|
|
public function transactionJournalMeta(): HasMany
|
2015-02-05 22:14:27 -06:00
|
|
|
{
|
2016-09-09 04:19:40 -05:00
|
|
|
return $this->hasMany('FireflyIII\Models\TransactionJournalMeta');
|
2015-02-05 22:14:27 -06:00
|
|
|
}
|
|
|
|
|
2016-02-10 09:26:42 -06:00
|
|
|
/**
|
2016-09-09 04:19:40 -05:00
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2016-02-10 09:26:42 -06:00
|
|
|
*/
|
2016-09-09 04:19:40 -05:00
|
|
|
public function transactionType()
|
2016-02-10 09:26:42 -06:00
|
|
|
{
|
2016-09-09 04:19:40 -05:00
|
|
|
return $this->belongsTo('FireflyIII\Models\TransactionType');
|
2016-02-10 09:26:42 -06:00
|
|
|
}
|
|
|
|
|
2015-02-11 00:35:10 -06:00
|
|
|
/**
|
2017-06-05 04:12:50 -05:00
|
|
|
* @return HasMany
|
2015-12-09 18:39:50 -06:00
|
|
|
*/
|
2017-06-05 04:12:50 -05:00
|
|
|
public function transactions(): HasMany
|
2015-12-09 18:39:50 -06:00
|
|
|
{
|
2016-01-27 11:31:44 -06:00
|
|
|
return $this->hasMany('FireflyIII\Models\Transaction');
|
2015-12-09 18:39:50 -06:00
|
|
|
}
|
2016-01-09 08:53:11 -06:00
|
|
|
|
|
|
|
/**
|
2016-01-27 11:31:44 -06:00
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2016-01-09 08:53:11 -06:00
|
|
|
*/
|
2016-01-27 11:31:44 -06:00
|
|
|
public function user()
|
2016-01-09 08:53:11 -06:00
|
|
|
{
|
2016-01-27 11:31:44 -06:00
|
|
|
return $this->belongsTo('FireflyIII\User');
|
2016-01-09 08:53:11 -06:00
|
|
|
}
|
2015-02-05 21:52:16 -06:00
|
|
|
}
|