Code cleanup

This commit is contained in:
James Cole
2024-12-22 08:43:12 +01:00
parent 5751f7e5a3
commit 565bd87959
574 changed files with 4600 additions and 4604 deletions

View File

@@ -94,6 +94,11 @@ class Account extends Model
return $this->belongsTo(User::class);
}
public function accountBalances(): HasMany
{
return $this->hasMany(AccountBalance::class);
}
public function accountType(): BelongsTo
{
return $this->belongsTo(AccountType::class);
@@ -123,11 +128,6 @@ class Account extends Model
return $this->hasMany(AccountMeta::class);
}
public function accountBalances(): HasMany
{
return $this->hasMany(AccountBalance::class);
}
public function getEditNameAttribute(): string
{
$name = $this->name;

View File

@@ -15,15 +15,8 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
class AccountBalance extends Model
{
use HasFactory;
protected $fillable = ['account_id', 'title', 'transaction_currency_id', 'balance', 'date', 'date_tz'];
protected function casts(): array
{
return [
'date' => SeparateTimezoneCaster::class,
'balance' => 'string',
];
}
protected $fillable = ['account_id', 'title', 'transaction_currency_id', 'balance', 'date', 'date_tz'];
public function account(): BelongsTo
{
@@ -34,4 +27,12 @@ class AccountBalance extends Model
{
return $this->belongsTo(TransactionCurrency::class);
}
protected function casts(): array
{
return [
'date' => SeparateTimezoneCaster::class,
'balance' => 'string',
];
}
}

View File

@@ -52,7 +52,7 @@ class AccountMeta extends Model
public function getDataAttribute(mixed $value): string
{
return (string)json_decode($value, true);
return (string) json_decode($value, true);
}
public function setDataAttribute(mixed $value): void

View File

@@ -23,7 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use FireflyIII\Enums\AccountTypeEnum;
use Deprecated;
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -35,46 +35,46 @@ class AccountType extends Model
{
use ReturnsIntegerIdTrait;
#[\Deprecated] /** @deprecated */
#[\Deprecated] /** @deprecated */
public const string ASSET = 'Asset account';
#[\Deprecated] /** @deprecated */
#[\Deprecated] /** @deprecated */
public const string BENEFICIARY = 'Beneficiary account';
#[\Deprecated] /** @deprecated */
#[\Deprecated] /** @deprecated */
public const string CASH = 'Cash account';
#[\Deprecated] /** @deprecated */
#[\Deprecated] /** @deprecated */
public const string CREDITCARD = 'Credit card';
#[\Deprecated] /** @deprecated */
#[\Deprecated] /** @deprecated */
public const string DEBT = 'Debt';
#[\Deprecated] /** @deprecated */
#[\Deprecated] /** @deprecated */
public const string DEFAULT = 'Default account';
#[\Deprecated] /** @deprecated */
#[\Deprecated] /** @deprecated */
public const string EXPENSE = 'Expense account';
#[\Deprecated] /** @deprecated */
#[\Deprecated] /** @deprecated */
public const string IMPORT = 'Import account';
#[\Deprecated] /** @deprecated */
#[\Deprecated] /** @deprecated */
public const string INITIAL_BALANCE = 'Initial balance account';
#[\Deprecated] /** @deprecated */
#[\Deprecated] /** @deprecated */
public const string LIABILITY_CREDIT = 'Liability credit account';
#[\Deprecated] /** @deprecated */
#[\Deprecated] /** @deprecated */
public const string LOAN = 'Loan';
#[\Deprecated] /** @deprecated */
#[\Deprecated] /** @deprecated */
public const string MORTGAGE = 'Mortgage';
#[\Deprecated] /** @deprecated */
#[\Deprecated] /** @deprecated */
public const string RECONCILIATION = 'Reconciliation account';
#[\Deprecated] /** @deprecated */
#[\Deprecated] /** @deprecated */
public const string REVENUE = 'Revenue account';
protected $casts

View File

@@ -61,7 +61,7 @@ class Attachment extends Model
public static function routeBinder(string $value): self
{
if (auth()->check()) {
$attachmentId = (int)$value;
$attachmentId = (int) $value;
/** @var User $user */
$user = auth()->user();
@@ -94,7 +94,7 @@ class Attachment extends Model
*/
public function fileName(): string
{
return sprintf('at-%s.data', (string)$this->id);
return sprintf('at-%s.data', (string) $this->id);
}
/**
@@ -108,7 +108,7 @@ class Attachment extends Model
protected function attachableId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -60,14 +60,14 @@ class AuditLogEntry extends Model
protected function auditableId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
protected function changerId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use FireflyIII\Enums\AutoBudgetType;
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
@@ -47,12 +46,12 @@ class AutoBudget extends Model
#[\Deprecated]
public const int AUTO_BUDGET_ROLLOVER = 2;
protected $casts
= [
'amount' => 'string',
];
protected $fillable = ['budget_id', 'amount', 'period'];
protected $casts = [
'amount' => 'string',
];
public function budget(): BelongsTo
{
return $this->belongsTo(Budget::class);
@@ -63,6 +62,20 @@ class AutoBudget extends Model
return $this->belongsTo(TransactionCurrency::class);
}
protected function amount(): Attribute
{
return Attribute::make(
get: static fn ($value) => (string) $value,
);
}
protected function budgetId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int) $value,
);
}
protected function casts(): array
{
return [
@@ -70,24 +83,10 @@ class AutoBudget extends Model
];
}
protected function amount(): Attribute
{
return Attribute::make(
get: static fn ($value) => (string)$value,
);
}
protected function budgetId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
);
}
protected function transactionCurrencyId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -62,7 +62,7 @@ class AvailableBudget extends Model
public static function routeBinder(string $value): self
{
if (auth()->check()) {
$availableBudgetId = (int)$value;
$availableBudgetId = (int) $value;
/** @var User $user */
$user = auth()->user();
@@ -90,14 +90,14 @@ class AvailableBudget extends Model
protected function amount(): Attribute
{
return Attribute::make(
get: static fn ($value) => (string)$value,
get: static fn ($value) => (string) $value,
);
}
protected function transactionCurrencyId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -93,7 +93,7 @@ class Bill extends Model
public static function routeBinder(string $value): self
{
if (auth()->check()) {
$billId = (int)$value;
$billId = (int) $value;
/** @var User $user */
$user = auth()->user();
@@ -139,7 +139,7 @@ class Bill extends Model
*/
public function setAmountMaxAttribute($value): void
{
$this->attributes['amount_max'] = (string)$value;
$this->attributes['amount_max'] = (string) $value;
}
/**
@@ -147,7 +147,7 @@ class Bill extends Model
*/
public function setAmountMinAttribute($value): void
{
$this->attributes['amount_min'] = (string)$value;
$this->attributes['amount_min'] = (string) $value;
}
public function transactionCurrency(): BelongsTo
@@ -166,7 +166,7 @@ class Bill extends Model
protected function amountMax(): Attribute
{
return Attribute::make(
get: static fn ($value) => (string)$value,
get: static fn ($value) => (string) $value,
);
}
@@ -176,14 +176,14 @@ class Bill extends Model
protected function amountMin(): Attribute
{
return Attribute::make(
get: static fn ($value) => (string)$value,
get: static fn ($value) => (string) $value,
);
}
protected function order(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
@@ -193,14 +193,14 @@ class Bill extends Model
protected function skip(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
protected function transactionCurrencyId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -65,7 +65,7 @@ class Budget extends Model
public static function routeBinder(string $value): self
{
if (auth()->check()) {
$budgetId = (int)$value;
$budgetId = (int) $value;
/** @var User $user */
$user = auth()->user();
@@ -121,7 +121,7 @@ class Budget extends Model
protected function order(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -67,7 +67,7 @@ class BudgetLimit extends Model
public static function routeBinder(string $value): self
{
if (auth()->check()) {
$budgetLimitId = (int)$value;
$budgetLimitId = (int) $value;
$budgetLimit = self::where('budget_limits.id', $budgetLimitId)
->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')
->where('budgets.user_id', auth()->user()->id)
@@ -86,11 +86,6 @@ class BudgetLimit extends Model
return $this->belongsTo(Budget::class);
}
public function transactionCurrency(): BelongsTo
{
return $this->belongsTo(TransactionCurrency::class);
}
/**
* Get all the notes.
*/
@@ -99,27 +94,32 @@ class BudgetLimit extends Model
return $this->morphMany(Note::class, 'noteable');
}
public function transactionCurrency(): BelongsTo
{
return $this->belongsTo(TransactionCurrency::class);
}
/**
* Get the amount
*/
protected function amount(): Attribute
{
return Attribute::make(
get: static fn ($value) => (string)$value,
get: static fn ($value) => (string) $value,
);
}
protected function budgetId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
protected function transactionCurrencyId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -63,7 +63,7 @@ class Category extends Model
public static function routeBinder(string $value): self
{
if (auth()->check()) {
$categoryId = (int)$value;
$categoryId = (int) $value;
/** @var User $user */
$user = auth()->user();

View File

@@ -72,28 +72,28 @@ class CurrencyExchangeRate extends Model
protected function fromCurrencyId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
protected function rate(): Attribute
{
return Attribute::make(
get: static fn ($value) => (string)$value,
get: static fn ($value) => (string) $value,
);
}
protected function toCurrencyId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
protected function userRate(): Attribute
{
return Attribute::make(
get: static fn ($value) => (string)$value,
get: static fn ($value) => (string) $value,
);
}
}

View File

@@ -59,7 +59,7 @@ class GroupMembership extends Model
protected function userRoleId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -53,7 +53,7 @@ class InvitedUser extends Model
public static function routeBinder(string $value): self
{
if (auth()->check()) {
$attemptId = (int)$value;
$attemptId = (int) $value;
/** @var null|InvitedUser $attempt */
$attempt = self::find($attemptId);

View File

@@ -55,7 +55,7 @@ class LinkType extends Model
public static function routeBinder(string $value): self
{
if (auth()->check()) {
$linkTypeId = (int)$value;
$linkTypeId = (int) $value;
$linkType = self::find($linkTypeId);
if (null !== $linkType) {
return $linkType;

View File

@@ -82,7 +82,7 @@ class Location extends Model
protected function locatableId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -57,7 +57,7 @@ class Note extends Model
protected function noteableId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -58,7 +58,7 @@ class ObjectGroup extends Model
public static function routeBinder(string $value): self
{
if (auth()->check()) {
$objectGroupId = (int)$value;
$objectGroupId = (int) $value;
/** @var null|ObjectGroup $objectGroup */
$objectGroup = self::where('object_groups.id', $objectGroupId)
@@ -104,7 +104,7 @@ class ObjectGroup extends Model
protected function order(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -65,7 +65,7 @@ class PiggyBank extends Model
public static function routeBinder(string $value): self
{
if (auth()->check()) {
$piggyBankId = (int)$value;
$piggyBankId = (int) $value;
$piggyBank = self::where('piggy_banks.id', $piggyBankId)
->leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
@@ -79,16 +79,16 @@ class PiggyBank extends Model
throw new NotFoundHttpException();
}
public function transactionCurrency(): BelongsTo
{
return $this->belongsTo(TransactionCurrency::class);
}
public function account(): BelongsTo
{
return $this->belongsTo(Account::class);
}
public function accounts(): BelongsToMany
{
return $this->belongsToMany(Account::class)->withPivot(['current_amount', 'native_current_amount']);
}
public function attachments(): MorphMany
{
return $this->morphMany(Attachment::class, 'attachable');
@@ -115,11 +115,6 @@ class PiggyBank extends Model
return $this->hasMany(PiggyBankEvent::class);
}
public function accounts(): BelongsToMany
{
return $this->belongsToMany(Account::class)->withPivot(['current_amount', 'native_current_amount']);
}
public function piggyBankRepetitions(): HasMany
{
return $this->hasMany(PiggyBankRepetition::class);
@@ -130,20 +125,25 @@ class PiggyBank extends Model
*/
public function setTargetAmountAttribute($value): void
{
$this->attributes['target_amount'] = (string)$value;
$this->attributes['target_amount'] = (string) $value;
}
public function transactionCurrency(): BelongsTo
{
return $this->belongsTo(TransactionCurrency::class);
}
protected function accountId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
protected function order(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
@@ -153,7 +153,7 @@ class PiggyBank extends Model
protected function targetAmount(): Attribute
{
return Attribute::make(
get: static fn ($value) => (string)$value,
get: static fn ($value) => (string) $value,
);
}
}

View File

@@ -58,7 +58,7 @@ class PiggyBankEvent extends Model
*/
public function setAmountAttribute($value): void
{
$this->attributes['amount'] = (string)$value;
$this->attributes['amount'] = (string) $value;
}
public function transactionJournal(): BelongsTo
@@ -72,14 +72,14 @@ class PiggyBankEvent extends Model
protected function amount(): Attribute
{
return Attribute::make(
get: static fn ($value) => (string)$value,
get: static fn ($value) => (string) $value,
);
}
protected function piggyBankId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -40,11 +40,11 @@ class PiggyBankRepetition extends Model
protected $casts
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',
'start_date' => SeparateTimezoneCaster::class,
'target_date' => SeparateTimezoneCaster::class,
'virtual_balance' => 'string',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'start_date' => SeparateTimezoneCaster::class,
'target_date' => SeparateTimezoneCaster::class,
'virtual_balance' => 'string',
];
protected $fillable = ['piggy_bank_id', 'start_date', 'start_date_tz', 'target_date', 'target_date_tz', 'current_amount'];
@@ -84,7 +84,7 @@ class PiggyBankRepetition extends Model
*/
public function setCurrentAmountAttribute($value): void
{
$this->attributes['current_amount'] = (string)$value;
$this->attributes['current_amount'] = (string) $value;
}
/**
@@ -93,14 +93,14 @@ class PiggyBankRepetition extends Model
protected function currentAmount(): Attribute
{
return Attribute::make(
get: static fn ($value) => (string)$value,
get: static fn ($value) => (string) $value,
);
}
protected function piggyBankId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -60,7 +60,7 @@ class Preference extends Model
// some preferences do not have an administration ID.
// some need it, to make sure the correct one is selected.
$userGroupId = (int)$user->user_group_id;
$userGroupId = (int) $user->user_group_id;
$userGroupId = 0 === $userGroupId ? null : $userGroupId;
/** @var null|Preference $preference */
@@ -77,7 +77,7 @@ class Preference extends Model
// try again with ID, but this time don't care about the preferred user_group_id
if (null === $preference) {
$preference = $user->preferences()->where('id', (int)$value)->first();
$preference = $user->preferences()->where('id', (int) $value)->first();
}
if (null !== $preference) {
return $preference;
@@ -87,7 +87,7 @@ class Preference extends Model
$preference = new self();
$preference->name = $value;
$preference->data = $default[$value];
$preference->user_id = (int)$user->id;
$preference->user_id = (int) $user->id;
$preference->user_group_id = in_array($value, $items, true) ? $userGroupId : null;
$preference->save();

View File

@@ -75,7 +75,7 @@ class Recurrence extends Model
public static function routeBinder(string $value): self
{
if (auth()->check()) {
$recurrenceId = (int)$value;
$recurrenceId = (int) $value;
/** @var User $user */
$user = auth()->user();
@@ -136,7 +136,7 @@ class Recurrence extends Model
protected function transactionTypeId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -60,7 +60,7 @@ class RecurrenceMeta extends Model
protected function recurrenceId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use FireflyIII\Enums\RecurrenceRepetitionWeekend;
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
@@ -67,6 +66,11 @@ class RecurrenceRepetition extends Model
/** @var string The table to store the data in */
protected $table = 'recurrences_repetitions';
public function recurrence(): BelongsTo
{
return $this->belongsTo(Recurrence::class);
}
protected function casts(): array
{
return [
@@ -74,29 +78,24 @@ class RecurrenceRepetition extends Model
];
}
public function recurrence(): BelongsTo
{
return $this->belongsTo(Recurrence::class);
}
protected function recurrenceId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
protected function repetitionSkip(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
protected function weekend(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -102,49 +102,49 @@ class RecurrenceTransaction extends Model
protected function amount(): Attribute
{
return Attribute::make(
get: static fn ($value) => (string)$value,
get: static fn ($value) => (string) $value,
);
}
protected function destinationId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
protected function foreignAmount(): Attribute
{
return Attribute::make(
get: static fn ($value) => (string)$value,
get: static fn ($value) => (string) $value,
);
}
protected function recurrenceId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
protected function sourceId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
protected function transactionCurrencyId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
protected function userId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -60,7 +60,7 @@ class RecurrenceTransactionMeta extends Model
protected function rtId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -64,7 +64,7 @@ class Rule extends Model
public static function routeBinder(string $value): self
{
if (auth()->check()) {
$ruleId = (int)$value;
$ruleId = (int) $value;
/** @var User $user */
$user = auth()->user();
@@ -115,14 +115,14 @@ class Rule extends Model
protected function order(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
protected function ruleGroupId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -54,7 +54,7 @@ class RuleAction extends Model
if (false === config('firefly.feature_flags.expression_engine')) {
Log::debug('Expression engine is disabled, returning action value as string.');
return (string)$this->action_value;
return (string) $this->action_value;
}
if (true === config('firefly.feature_flags.expression_engine') && str_starts_with($this->action_value, '\=')) {
// return literal string.
@@ -66,7 +66,7 @@ class RuleAction extends Model
$result = $expr->evaluate($journal);
} catch (SyntaxError $e) {
Log::error(sprintf('Expression engine failed to evaluate expression "%s" with error "%s".', $this->action_value, $e->getMessage()));
$result = (string)$this->action_value;
$result = (string) $this->action_value;
}
Log::debug(sprintf('Expression engine is enabled, result of expression "%s" is "%s".', $this->action_value, $result));
@@ -81,14 +81,14 @@ class RuleAction extends Model
protected function order(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
protected function ruleId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -62,7 +62,7 @@ class RuleGroup extends Model
public static function routeBinder(string $value): self
{
if (auth()->check()) {
$ruleGroupId = (int)$value;
$ruleGroupId = (int) $value;
/** @var User $user */
$user = auth()->user();
@@ -90,7 +90,7 @@ class RuleGroup extends Model
protected function order(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -54,14 +54,14 @@ class RuleTrigger extends Model
protected function order(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
protected function ruleId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -66,7 +66,7 @@ class Tag extends Model
public static function routeBinder(string $value): self
{
if (auth()->check()) {
$tagId = (int)$value;
$tagId = (int) $value;
/** @var User $user */
$user = auth()->user();

View File

@@ -163,7 +163,7 @@ class Transaction extends Model
*/
public function setAmountAttribute($value): void
{
$this->attributes['amount'] = (string)$value;
$this->attributes['amount'] = (string) $value;
}
public function transactionCurrency(): BelongsTo
@@ -179,14 +179,7 @@ class Transaction extends Model
protected function accountId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
);
}
protected function balanceDirty(): Attribute
{
return Attribute::make(
get: static fn ($value) => 1 === (int)$value,
get: static fn ($value) => (int) $value,
);
}
@@ -196,7 +189,14 @@ class Transaction extends Model
protected function amount(): Attribute
{
return Attribute::make(
get: static fn ($value) => (string)$value,
get: static fn ($value) => (string) $value,
);
}
protected function balanceDirty(): Attribute
{
return Attribute::make(
get: static fn ($value) => 1 === (int) $value,
);
}
@@ -206,14 +206,14 @@ class Transaction extends Model
protected function foreignAmount(): Attribute
{
return Attribute::make(
get: static fn ($value) => (string)$value,
get: static fn ($value) => (string) $value,
);
}
protected function transactionJournalId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -61,7 +61,7 @@ class TransactionCurrency extends Model
public static function routeBinder(string $value): self
{
if (auth()->check()) {
$currencyId = (int)$value;
$currencyId = (int) $value;
$currency = self::find($currencyId);
if (null !== $currency) {
$currency->refreshForUser(auth()->user());
@@ -115,7 +115,7 @@ class TransactionCurrency extends Model
protected function decimalPlaces(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -62,7 +62,7 @@ class TransactionGroup extends Model
{
app('log')->debug(sprintf('Now in %s("%s")', __METHOD__, $value));
if (auth()->check()) {
$groupId = (int)$value;
$groupId = (int) $value;
/** @var User $user */
$user = auth()->user();

View File

@@ -54,7 +54,7 @@ class TransactionJournalLink extends Model
public static function routeBinder(string $value): self
{
if (auth()->check()) {
$linkId = (int)$value;
$linkId = (int) $value;
$link = self::where('journal_links.id', $linkId)
->leftJoin('transaction_journals as t_a', 't_a.id', '=', 'source_id')
->leftJoin('transaction_journals as t_b', 't_b.id', '=', 'destination_id')
@@ -96,21 +96,21 @@ class TransactionJournalLink extends Model
protected function destinationId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
protected function linkTypeId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
protected function sourceId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -66,7 +66,7 @@ class TransactionJournalMeta extends Model
{
$data = json_encode($value);
$this->attributes['data'] = $data;
$this->attributes['hash'] = hash('sha256', (string)$data);
$this->attributes['hash'] = hash('sha256', (string) $data);
}
public function transactionJournal(): BelongsTo
@@ -77,7 +77,7 @@ class TransactionJournalMeta extends Model
protected function transactionJournalId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -67,13 +66,6 @@ class TransactionType extends Model
];
protected $fillable = ['type'];
protected function casts(): array
{
return [
// 'type' => TransactionTypeEnum::class,
];
}
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
@@ -116,4 +108,11 @@ class TransactionType extends Model
{
return $this->hasMany(TransactionJournal::class);
}
protected function casts(): array
{
return [
// 'type' => TransactionTypeEnum::class,
];
}
}

View File

@@ -51,7 +51,7 @@ class UserGroup extends Model
public static function routeBinder(string $value): self
{
if (auth()->check()) {
$userGroupId = (int)$value;
$userGroupId = (int) $value;
/** @var User $user */
$user = auth()->user();

View File

@@ -54,15 +54,6 @@ class Webhook extends Model
];
protected $fillable = ['active', 'trigger', 'response', 'delivery', 'user_id', 'user_group_id', 'url', 'title', 'secret'];
protected function casts(): array
{
return [
// 'delivery' => WebhookDelivery::class,
// 'response' => WebhookResponse::class,
// 'trigger' => WebhookTrigger::class,
];
}
public static function getDeliveries(): array
{
$array = [];
@@ -164,4 +155,13 @@ class Webhook extends Model
{
return $this->hasMany(WebhookMessage::class);
}
protected function casts(): array
{
return [
// 'delivery' => WebhookDelivery::class,
// 'response' => WebhookResponse::class,
// 'trigger' => WebhookTrigger::class,
];
}
}

View File

@@ -48,7 +48,7 @@ class WebhookAttempt extends Model
public static function routeBinder(string $value): self
{
if (auth()->check()) {
$attemptId = (int)$value;
$attemptId = (int) $value;
/** @var User $user */
$user = auth()->user();
@@ -71,7 +71,7 @@ class WebhookAttempt extends Model
protected function webhookMessageId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}

View File

@@ -56,7 +56,7 @@ class WebhookMessage extends Model
public static function routeBinder(string $value): self
{
if (auth()->check()) {
$messageId = (int)$value;
$messageId = (int) $value;
/** @var User $user */
$user = auth()->user();
@@ -87,14 +87,14 @@ class WebhookMessage extends Model
protected function sent(): Attribute
{
return Attribute::make(
get: static fn ($value) => (bool)$value,
get: static fn ($value) => (bool) $value,
);
}
protected function webhookId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn ($value) => (int) $value,
);
}
}