mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Code cleanup.
This commit is contained in:
@@ -38,54 +38,57 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
/**
|
||||
* FireflyIII\Models\Transaction
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property bool $reconciled
|
||||
* @property int $account_id
|
||||
* @property int $transaction_journal_id
|
||||
* @property string|null $description
|
||||
* @property int|null $transaction_currency_id
|
||||
* @property string|int|null $modified
|
||||
* @property string|int|null $modified_foreign
|
||||
* @property string $date
|
||||
* @property string $max_date
|
||||
* @property string $amount
|
||||
* @property string|null $foreign_amount
|
||||
* @property int|null $foreign_currency_id
|
||||
* @property int $identifier
|
||||
* @property-read Account $account
|
||||
* @property-read Collection|Budget[] $budgets
|
||||
* @property-read int|null $budgets_count
|
||||
* @property-read Collection|Category[] $categories
|
||||
* @property-read int|null $categories_count
|
||||
* @property-read TransactionCurrency|null $foreignCurrency
|
||||
* @property-read TransactionCurrency|null $transactionCurrency
|
||||
* @property-read TransactionJournal $transactionJournal
|
||||
* @method static Builder|Transaction after(Carbon $date)
|
||||
* @method static Builder|Transaction before(Carbon $date)
|
||||
* @method static Builder|Transaction newModelQuery()
|
||||
* @method static Builder|Transaction newQuery()
|
||||
* @property int $id
|
||||
* @property null|Carbon $created_at
|
||||
* @property null|Carbon $updated_at
|
||||
* @property null|Carbon $deleted_at
|
||||
* @property bool $reconciled
|
||||
* @property int $account_id
|
||||
* @property int $transaction_journal_id
|
||||
* @property null|string $description
|
||||
* @property null|int $transaction_currency_id
|
||||
* @property null|int|string $modified
|
||||
* @property null|int|string $modified_foreign
|
||||
* @property string $date
|
||||
* @property string $max_date
|
||||
* @property string $amount
|
||||
* @property null|string $foreign_amount
|
||||
* @property null|int $foreign_currency_id
|
||||
* @property int $identifier
|
||||
* @property Account $account
|
||||
* @property Budget[]|Collection $budgets
|
||||
* @property null|int $budgets_count
|
||||
* @property Category[]|Collection $categories
|
||||
* @property null|int $categories_count
|
||||
* @property null|TransactionCurrency $foreignCurrency
|
||||
* @property null|TransactionCurrency $transactionCurrency
|
||||
* @property TransactionJournal $transactionJournal
|
||||
*
|
||||
* @method static Builder|Transaction after(Carbon $date)
|
||||
* @method static Builder|Transaction before(Carbon $date)
|
||||
* @method static Builder|Transaction newModelQuery()
|
||||
* @method static Builder|Transaction newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Transaction onlyTrashed()
|
||||
* @method static Builder|Transaction query()
|
||||
* @method static Builder|Transaction transactionTypes($types)
|
||||
* @method static Builder|Transaction whereAccountId($value)
|
||||
* @method static Builder|Transaction whereAmount($value)
|
||||
* @method static Builder|Transaction whereCreatedAt($value)
|
||||
* @method static Builder|Transaction whereDeletedAt($value)
|
||||
* @method static Builder|Transaction whereDescription($value)
|
||||
* @method static Builder|Transaction whereForeignAmount($value)
|
||||
* @method static Builder|Transaction whereForeignCurrencyId($value)
|
||||
* @method static Builder|Transaction whereId($value)
|
||||
* @method static Builder|Transaction whereIdentifier($value)
|
||||
* @method static Builder|Transaction whereReconciled($value)
|
||||
* @method static Builder|Transaction whereTransactionCurrencyId($value)
|
||||
* @method static Builder|Transaction whereTransactionJournalId($value)
|
||||
* @method static Builder|Transaction whereUpdatedAt($value)
|
||||
* @method static Builder|Transaction query()
|
||||
* @method static Builder|Transaction transactionTypes($types)
|
||||
* @method static Builder|Transaction whereAccountId($value)
|
||||
* @method static Builder|Transaction whereAmount($value)
|
||||
* @method static Builder|Transaction whereCreatedAt($value)
|
||||
* @method static Builder|Transaction whereDeletedAt($value)
|
||||
* @method static Builder|Transaction whereDescription($value)
|
||||
* @method static Builder|Transaction whereForeignAmount($value)
|
||||
* @method static Builder|Transaction whereForeignCurrencyId($value)
|
||||
* @method static Builder|Transaction whereId($value)
|
||||
* @method static Builder|Transaction whereIdentifier($value)
|
||||
* @method static Builder|Transaction whereReconciled($value)
|
||||
* @method static Builder|Transaction whereTransactionCurrencyId($value)
|
||||
* @method static Builder|Transaction whereTransactionJournalId($value)
|
||||
* @method static Builder|Transaction whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Transaction withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Transaction withoutTrashed()
|
||||
* @property int|string $the_count
|
||||
*
|
||||
* @property int|string $the_count
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Transaction extends Model
|
||||
@@ -94,7 +97,6 @@ class Transaction extends Model
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
@@ -123,8 +125,6 @@ class Transaction extends Model
|
||||
|
||||
/**
|
||||
* Get the account this object belongs to.
|
||||
*
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function account(): BelongsTo
|
||||
{
|
||||
@@ -133,8 +133,6 @@ class Transaction extends Model
|
||||
|
||||
/**
|
||||
* Get the budget(s) this object belongs to.
|
||||
*
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function budgets(): BelongsToMany
|
||||
{
|
||||
@@ -143,8 +141,6 @@ class Transaction extends Model
|
||||
|
||||
/**
|
||||
* Get the category(ies) this object belongs to.
|
||||
*
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function categories(): BelongsToMany
|
||||
{
|
||||
@@ -153,8 +149,6 @@ class Transaction extends Model
|
||||
|
||||
/**
|
||||
* Get the currency this object belongs to.
|
||||
*
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function foreignCurrency(): BelongsTo
|
||||
{
|
||||
@@ -163,10 +157,6 @@ class Transaction extends Model
|
||||
|
||||
/**
|
||||
* Check for transactions AFTER a specified date.
|
||||
*
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param Carbon $date
|
||||
*/
|
||||
public function scopeAfter(Builder $query, Carbon $date): void
|
||||
{
|
||||
@@ -178,11 +168,6 @@ class Transaction extends Model
|
||||
|
||||
/**
|
||||
* Check if a table is joined.
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $table
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isJoined(Builder $query, string $table): bool
|
||||
{
|
||||
@@ -199,10 +184,6 @@ class Transaction extends Model
|
||||
|
||||
/**
|
||||
* Check for transactions BEFORE the specified date.
|
||||
*
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param Carbon $date
|
||||
*/
|
||||
public function scopeBefore(Builder $query, Carbon $date): void
|
||||
{
|
||||
@@ -212,11 +193,6 @@ class Transaction extends Model
|
||||
$query->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param array $types
|
||||
*/
|
||||
public function scopeTransactionTypes(Builder $query, array $types): void
|
||||
{
|
||||
if (!self::isJoined($query, 'transaction_journals')) {
|
||||
@@ -230,7 +206,6 @@ class Transaction extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setAmountAttribute($value): void
|
||||
@@ -238,63 +213,47 @@ class Transaction extends Model
|
||||
$this->attributes['amount'] = (string)$value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function transactionCurrency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionCurrency::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function transactionJournal(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionJournal::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function accountId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount
|
||||
*
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function amount(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (string)$value,
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the foreign amount
|
||||
*
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function foreignAmount(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (string)$value,
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function transactionJournalId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
get: static fn ($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user