From 67a048c2799fafba4006f332a8c4e3013f5f9469 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 21 May 2026 06:38:35 +0200 Subject: [PATCH] Fix issues. --- app/Http/Middleware/Range.php | 2 +- app/Models/AccountType.php | 10 +++----- app/Models/AutoBudget.php | 19 ++++++--------- app/Models/RecurrenceRepetition.php | 28 +++++++++------------ app/Models/TransactionType.php | 16 ++++++------ app/Models/Webhook.php | 38 +++++++++++++---------------- app/Support/System/OAuthKeys.php | 4 +-- 7 files changed, 50 insertions(+), 67 deletions(-) diff --git a/app/Http/Middleware/Range.php b/app/Http/Middleware/Range.php index 3df7724625..94b2f34789 100644 --- a/app/Http/Middleware/Range.php +++ b/app/Http/Middleware/Range.php @@ -73,7 +73,7 @@ class Range app('view')->share('listLength', $pref); // share security message: - if (FireflyConfig::query()->has('upgrade_security_message') && FireflyConfig::query()->has('upgrade_security_level')) { + if (FireflyConfig::has('upgrade_security_message') && FireflyConfig::has('upgrade_security_level')) { app('view')->share('upgrade_security_message', FireflyConfig::get('upgrade_security_message')->data); app('view')->share('upgrade_security_level', FireflyConfig::get('upgrade_security_level')->data); } diff --git a/app/Models/AccountType.php b/app/Models/AccountType.php index bc8cefa84d..3fb1c07741 100644 --- a/app/Models/AccountType.php +++ b/app/Models/AccountType.php @@ -31,7 +31,9 @@ class AccountType extends Model { use ReturnsIntegerIdTrait; - protected $casts = ['created_at' => 'datetime', 'updated_at' => 'datetime']; + protected function casts(): array { + return ['created_at' => 'datetime', 'updated_at' => 'datetime']; + } protected $fillable = ['type']; @@ -40,10 +42,4 @@ class AccountType extends Model return $this->hasMany(Account::class); } - protected function casts(): array - { - return [ - // 'type' => AccountTypeEnum::class, - ]; - } } diff --git a/app/Models/AutoBudget.php b/app/Models/AutoBudget.php index 315e43daa6..7a06e8781c 100644 --- a/app/Models/AutoBudget.php +++ b/app/Models/AutoBudget.php @@ -41,7 +41,11 @@ class AutoBudget extends Model use ReturnsIntegerIdTrait; use SoftDeletes; - protected $casts = ['amount' => 'string', 'native_amount' => 'string']; + protected function casts(): array + { + return ['amount' => 'string', 'native_amount' => 'string']; + } + protected $fillable = ['budget_id', 'amount', 'period', 'native_amount']; public function budget(): BelongsTo @@ -56,23 +60,16 @@ class AutoBudget extends Model protected function amount(): Attribute { - return Attribute::make(get: static fn ($value): string => (string) $value); + return Attribute::make(get: static fn($value): string => (string)$value); } protected function budgetId(): Attribute { - return Attribute::make(get: static fn ($value): int => (int) $value); - } - - protected function casts(): array - { - return [ - // 'auto_budget_type' => AutoBudgetType::class, - ]; + return Attribute::make(get: static fn($value): int => (int)$value); } protected function transactionCurrencyId(): Attribute { - return Attribute::make(get: static fn ($value): int => (int) $value); + return Attribute::make(get: static fn($value): int => (int)$value); } } diff --git a/app/Models/RecurrenceRepetition.php b/app/Models/RecurrenceRepetition.php index 746fe6e13d..42e6781d35 100644 --- a/app/Models/RecurrenceRepetition.php +++ b/app/Models/RecurrenceRepetition.php @@ -35,15 +35,18 @@ class RecurrenceRepetition extends Model use ReturnsIntegerIdTrait; use SoftDeletes; - protected $casts = [ - 'created_at' => 'datetime', - 'updated_at' => 'datetime', - 'deleted_at' => 'datetime', - 'repetition_type' => 'string', - 'repetition_moment' => 'string', - 'repetition_skip' => 'int', - 'weekend' => 'int', - ]; + protected function casts(): array + { + return [ + 'created_at' => 'datetime', + 'updated_at' => 'datetime', + 'deleted_at' => 'datetime', + 'repetition_type' => 'string', + 'repetition_moment' => 'string', + 'repetition_skip' => 'int', + 'weekend' => 'int', + ]; + } protected $fillable = ['recurrence_id', 'weekend', 'repetition_type', 'repetition_moment', 'repetition_skip']; @@ -54,13 +57,6 @@ class RecurrenceRepetition extends Model return $this->belongsTo(Recurrence::class); } - protected function casts(): array - { - return [ - // 'weekend' => RecurrenceRepetitionWeekend::class, - ]; - } - protected function recurrenceId(): Attribute { return Attribute::make(get: static fn ($value): int => (int) $value); diff --git a/app/Models/TransactionType.php b/app/Models/TransactionType.php index cfb4a4656b..a2ac9e86b9 100644 --- a/app/Models/TransactionType.php +++ b/app/Models/TransactionType.php @@ -35,7 +35,11 @@ class TransactionType extends Model use ReturnsIntegerIdTrait; use SoftDeletes; - protected $casts = ['created_at' => 'datetime', 'updated_at' => 'datetime', 'deleted_at' => 'datetime']; + protected function casts(): array + { + return ['created_at' => 'datetime', 'updated_at' => 'datetime', 'deleted_at' => 'datetime']; + } + protected $fillable = ['type']; /** @@ -43,13 +47,13 @@ class TransactionType extends Model * * @throws NotFoundHttpException */ - public static function routeBinder(self|string $value): self + public static function routeBinder(self | string $value): self { if (!auth()->check()) { throw new NotFoundHttpException(); } if ($value instanceof self) { - $value = (string) $value->type; + $value = (string)$value->type; } $transactionType = self::where('type', ucfirst($value))->first(); if (null !== $transactionType) { @@ -84,10 +88,4 @@ class TransactionType extends Model return $this->hasMany(TransactionJournal::class); } - protected function casts(): array - { - return [ - // 'type' => TransactionTypeEnum::class, - ]; - } } diff --git a/app/Models/Webhook.php b/app/Models/Webhook.php index c6f4f330b9..01b53e7cb4 100644 --- a/app/Models/Webhook.php +++ b/app/Models/Webhook.php @@ -46,14 +46,18 @@ class Webhook extends Model use ReturnsIntegerUserIdTrait; use SoftDeletes; - protected $casts = [ - 'active' => 'boolean', - 'trigger' => 'integer', - 'response' => 'integer', - 'delivery' => 'integer', - 'user_id' => 'integer', - 'user_group_id' => 'integer', - ]; + protected function casts(): array + { + return [ + 'active' => 'boolean', + 'trigger' => 'integer', + 'response' => 'integer', + 'delivery' => 'integer', + 'user_id' => 'integer', + 'user_group_id' => 'integer', + ]; + } + protected $fillable = ['active', 'trigger', 'response', 'delivery', 'user_id', 'user_group_id', 'url', 'title', 'secret']; public static function getDeliveries(): array @@ -130,19 +134,19 @@ class Webhook extends Model * * @throws NotFoundHttpException */ - public static function routeBinder(self|string $value): self + public static function routeBinder(self | string $value): self { if (auth()->check()) { if ($value instanceof self) { - $value = (int) $value->id; + $value = (int)$value->id; } - $webhookId = (int) $value; + $webhookId = (int)$value; /** @var User $user */ - $user = auth()->user(); + $user = auth()->user(); /** @var null|Webhook $webhook */ - $webhook = $user->webhooks()->find($webhookId); + $webhook = $user->webhooks()->find($webhookId); if (null !== $webhook) { return $webhook; } @@ -176,12 +180,4 @@ class Webhook extends Model return $this->belongsToMany(WebhookTrigger::class); } - protected function casts(): array - { - return [ - // 'delivery' => WebhookDelivery::class, - // 'response' => WebhookResponse::class, - // 'trigger' => WebhookTrigger::class, - ]; - } } diff --git a/app/Support/System/OAuthKeys.php b/app/Support/System/OAuthKeys.php index 764e04c32c..22ca659ec8 100644 --- a/app/Support/System/OAuthKeys.php +++ b/app/Support/System/OAuthKeys.php @@ -78,8 +78,8 @@ class OAuthKeys $privateKey = ''; $publicKey = ''; // better check if keys are in the database: - $hasPrivate = FireflyConfig::query()->has(self::PRIVATE_KEY); - $hasPublic = FireflyConfig::query()->has(self::PUBLIC_KEY); + $hasPrivate = FireflyConfig::has(self::PRIVATE_KEY); + $hasPublic = FireflyConfig::has(self::PUBLIC_KEY); Log::debug(sprintf('keysInDatabase: hasPrivate:%s, hasPublic:%s', var_export($hasPrivate, true), var_export($hasPublic, true)));