From a14c9438ade70ebce4d7c4ea8a638dc1df9e6c4a Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 28 Aug 2021 15:47:09 +0200 Subject: [PATCH] Minor code cleanup. --- app/Models/Account.php | 66 +++++++------- app/Models/AccountMeta.php | 3 +- app/Models/AccountType.php | 3 +- app/Models/Attachment.php | 12 +-- app/Models/AvailableBudget.php | 17 ++-- app/Models/Budget.php | 8 +- app/Models/BudgetLimit.php | 12 +-- app/Models/Category.php | 21 ++--- app/Models/Configuration.php | 9 +- app/Models/CurrencyExchangeRate.php | 8 +- app/Models/LinkType.php | 14 +-- app/Models/Location.php | 2 + app/Models/ObjectGroup.php | 57 ++++++------ app/Models/PiggyBank.php | 55 ++++++------ app/Models/PiggyBankEvent.php | 11 +-- app/Models/PiggyBankRepetition.php | 10 +-- app/Models/Preference.php | 14 +-- app/Models/Recurrence.php | 32 +++---- app/Models/RecurrenceMeta.php | 2 + app/Models/RecurrenceRepetition.php | 10 ++- app/Models/RecurrenceTransaction.php | 11 ++- app/Models/RecurrenceTransactionMeta.php | 2 + app/Models/Rule.php | 38 ++++---- app/Models/RuleAction.php | 6 +- app/Models/RuleGroup.php | 18 ++-- app/Models/RuleTrigger.php | 6 +- app/Models/Transaction.php | 107 ++++++++++++----------- app/Models/TransactionCurrency.php | 13 +-- app/Models/TransactionGroup.php | 5 +- app/Models/TransactionJournalLink.php | 10 +-- app/Models/TransactionJournalMeta.php | 1 + app/Models/Webhook.php | 11 ++- app/Models/WebhookAttempt.php | 18 ++-- app/Models/WebhookMessage.php | 2 +- 34 files changed, 321 insertions(+), 293 deletions(-) diff --git a/app/Models/Account.php b/app/Models/Account.php index d52052a22a..5e9d93d8cc 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -39,8 +39,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Class Account * - * @property int $id - * @property \Illuminate\Support\Carbon|null $created_at + * @property int $id + * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at * @property \Illuminate\Support\Carbon|null $deleted_at * @property int $user_id @@ -89,16 +89,16 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @method static Builder|Account withTrashed() * @method static Builder|Account withoutTrashed() * @mixin Eloquent - * @property Carbon $lastActivityDate - * @property string $startBalance - * @property string $endBalance - * @property string $difference - * @property string $interest - * @property string $interestPeriod - * @property string $accountTypeString - * @property string $location - * @property string $liability_direction - * @property string $current_debt + * @property Carbon $lastActivityDate + * @property string $startBalance + * @property string $endBalance + * @property string $difference + * @property string $interest + * @property string $interestPeriod + * @property string $accountTypeString + * @property string $location + * @property string $liability_direction + * @property string $current_debt */ class Account extends Model { @@ -149,11 +149,12 @@ class Account extends Model } /** - * Get all of the tags for the post. + * @return BelongsTo + * @codeCoverageIgnore */ - public function objectGroups() + public function accountType(): BelongsTo { - return $this->morphToMany(ObjectGroup::class, 'object_groupable'); + return $this->belongsTo(AccountType::class); } /** @@ -165,24 +166,6 @@ class Account extends Model return $this->morphMany(Attachment::class, 'attachable'); } - /** - * @return HasMany - * @codeCoverageIgnore - */ - public function accountMeta(): HasMany - { - return $this->hasMany(AccountMeta::class); - } - - /** - * @return BelongsTo - * @codeCoverageIgnore - */ - public function accountType(): BelongsTo - { - return $this->belongsTo(AccountType::class); - } - /** * Get the account number. * @@ -198,6 +181,15 @@ class Account extends Model return $metaValue ? $metaValue->data : ''; } + /** + * @return HasMany + * @codeCoverageIgnore + */ + public function accountMeta(): HasMany + { + return $this->hasMany(AccountMeta::class); + } + /** * @return string * @codeCoverageIgnore @@ -231,6 +223,14 @@ class Account extends Model return $this->morphMany(Note::class, 'noteable'); } + /** + * Get all of the tags for the post. + */ + public function objectGroups() + { + return $this->morphToMany(ObjectGroup::class, 'object_groupable'); + } + /** * @return HasMany * @codeCoverageIgnore diff --git a/app/Models/AccountMeta.php b/app/Models/AccountMeta.php index a8e30bb54e..4f41f9aaf9 100644 --- a/app/Models/AccountMeta.php +++ b/app/Models/AccountMeta.php @@ -27,6 +27,7 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Support\Carbon; +use JsonException; /** * Class AccountMeta @@ -79,7 +80,7 @@ class AccountMeta extends Model * @param mixed $value * * @return mixed - * @throws \JsonException + * @throws JsonException * @codeCoverageIgnore */ public function getDataAttribute($value) diff --git a/app/Models/AccountType.php b/app/Models/AccountType.php index 11d821fb8c..c2c90132d7 100644 --- a/app/Models/AccountType.php +++ b/app/Models/AccountType.php @@ -28,6 +28,7 @@ use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Support\Carbon; + /** * FireflyIII\Models\AccountType * @@ -74,7 +75,7 @@ class AccountType extends Model public const MORTGAGE = 'Mortgage'; /** @var string */ public const CREDITCARD = 'Credit card'; - /** @var string */ + /** @var string */ public const LIABILITY_CREDIT = 'Liability credit account'; /** * The attributes that should be casted to native types. diff --git a/app/Models/Attachment.php b/app/Models/Attachment.php index a75c612e88..6b2284ca20 100644 --- a/app/Models/Attachment.php +++ b/app/Models/Attachment.php @@ -37,12 +37,12 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * FireflyIII\Models\Attachment * - * @property int $id - * @property Carbon|null $created_at - * @property Carbon|null $updated_at - * @property Carbon|null $deleted_at - * @property int $user_id - * @property int $attachable_id + * @property int $id + * @property Carbon|null $created_at + * @property Carbon|null $updated_at + * @property Carbon|null $deleted_at + * @property int $user_id + * @property int $attachable_id * @property string $attachable_type * @property bool $file_exists * @property string $md5 diff --git a/app/Models/AvailableBudget.php b/app/Models/AvailableBudget.php index e982f99167..20a4241fb1 100644 --- a/app/Models/AvailableBudget.php +++ b/app/Models/AvailableBudget.php @@ -22,27 +22,27 @@ declare(strict_types=1); namespace FireflyIII\Models; -use Carbon\Carbon; use Eloquent; use FireflyIII\User; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Query\Builder; +use Illuminate\Support\Carbon; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * FireflyIII\Models\AvailableBudget * * @property int $id - * @property \Illuminate\Support\Carbon|null $created_at - * @property \Illuminate\Support\Carbon|null $updated_at - * @property \Illuminate\Support\Carbon|null $deleted_at + * @property Carbon|null $created_at + * @property Carbon|null $updated_at + * @property Carbon|null $deleted_at * @property int $user_id * @property int $transaction_currency_id * @property string $amount - * @property \Illuminate\Support\Carbon $start_date - * @property \Illuminate\Support\Carbon $end_date + * @property Carbon $start_date + * @property Carbon $end_date * @property-read TransactionCurrency $transactionCurrency * @property-read User $user * @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget newModelQuery() @@ -65,6 +65,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class AvailableBudget extends Model { use SoftDeletes; + /** * The attributes that should be casted to native types. * @@ -87,13 +88,13 @@ class AvailableBudget extends Model * * @param string $value * - * @throws NotFoundHttpException * @return AvailableBudget + * @throws NotFoundHttpException */ public static function routeBinder(string $value): AvailableBudget { if (auth()->check()) { - $availableBudgetId = (int) $value; + $availableBudgetId = (int)$value; /** @var User $user */ $user = auth()->user(); /** @var AvailableBudget $availableBudget */ diff --git a/app/Models/Budget.php b/app/Models/Budget.php index c0ed5391a6..184b37d57c 100644 --- a/app/Models/Budget.php +++ b/app/Models/Budget.php @@ -39,9 +39,9 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * FireflyIII\Models\Budget * * @property int $id - * @property Carbon|null $created_at - * @property Carbon|null $updated_at - * @property Carbon|null $deleted_at + * @property Carbon|null $created_at + * @property Carbon|null $updated_at + * @property Carbon|null $deleted_at * @property int $user_id * @property string $name * @property bool $active @@ -74,7 +74,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @method static Builder|Budget withTrashed() * @method static Builder|Budget withoutTrashed() * @mixin Eloquent - * @property string $email + * @property string $email */ class Budget extends Model { diff --git a/app/Models/BudgetLimit.php b/app/Models/BudgetLimit.php index 5754b544fc..e05a37e28c 100644 --- a/app/Models/BudgetLimit.php +++ b/app/Models/BudgetLimit.php @@ -22,23 +22,23 @@ declare(strict_types=1); namespace FireflyIII\Models; -use Carbon\Carbon; use Eloquent; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Support\Carbon; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * FireflyIII\Models\BudgetLimit * - * @property int $id - * @property \Illuminate\Support\Carbon|null $created_at - * @property \Illuminate\Support\Carbon|null $updated_at + * @property int $id + * @property Carbon|null $created_at + * @property Carbon|null $updated_at * @property int $budget_id * @property int|null $transaction_currency_id - * @property \Illuminate\Support\Carbon $start_date - * @property \Illuminate\Support\Carbon|null $end_date + * @property Carbon $start_date + * @property Carbon|null $end_date * @property string $amount * @property string $spent * @property string|null $period diff --git a/app/Models/Category.php b/app/Models/Category.php index 5cb8b8aca8..c23eb0cd5e 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -96,13 +96,13 @@ class Category extends Model * * @param string $value * - * @throws NotFoundHttpException * @return Category + * @throws NotFoundHttpException */ public static function routeBinder(string $value): Category { if (auth()->check()) { - $categoryId = (int) $value; + $categoryId = (int)$value; /** @var User $user */ $user = auth()->user(); /** @var Category $category */ @@ -114,14 +114,6 @@ class Category extends Model throw new NotFoundHttpException; } - /** - * @codeCoverageIgnore - * @return BelongsToMany - */ - public function transactionJournals(): BelongsToMany - { - return $this->belongsToMany(TransactionJournal::class, 'category_transaction_journal', 'category_id'); - } /** * @codeCoverageIgnore * @return MorphMany @@ -140,6 +132,15 @@ class Category extends Model return $this->morphMany(Note::class, 'noteable'); } + /** + * @codeCoverageIgnore + * @return BelongsToMany + */ + public function transactionJournals(): BelongsToMany + { + return $this->belongsToMany(TransactionJournal::class, 'category_transaction_journal', 'category_id'); + } + /** * @codeCoverageIgnore * @return BelongsToMany diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php index 865e378338..e3b19b6bec 100644 --- a/app/Models/Configuration.php +++ b/app/Models/Configuration.php @@ -31,12 +31,12 @@ use Illuminate\Support\Carbon; /** * FireflyIII\Models\Configuration * - * @property int $id + * @property int $id * @property Carbon|null $created_at * @property Carbon|null $updated_at * @property Carbon|null $deleted_at - * @property string $name - * @property mixed $data + * @property string $name + * @property mixed $data * @method static \Illuminate\Database\Eloquent\Builder|Configuration newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|Configuration newQuery() * @method static Builder|Configuration onlyTrashed() @@ -70,7 +70,8 @@ class Configuration extends Model protected $table = 'configuration'; /** -* See reference nr. 17 + * See reference nr. 17 + * * @codeCoverageIgnore * * @param mixed $value diff --git a/app/Models/CurrencyExchangeRate.php b/app/Models/CurrencyExchangeRate.php index dcccc1ba76..fdc4fcd3a5 100644 --- a/app/Models/CurrencyExchangeRate.php +++ b/app/Models/CurrencyExchangeRate.php @@ -22,24 +22,24 @@ declare(strict_types=1); namespace FireflyIII\Models; -use Carbon\Carbon; use Eloquent; use FireflyIII\User; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Support\Carbon; /** * FireflyIII\Models\CurrencyExchangeRate * * @property int $id - * @property \Illuminate\Support\Carbon|null $created_at - * @property \Illuminate\Support\Carbon|null $updated_at + * @property Carbon|null $created_at + * @property Carbon|null $updated_at * @property string|null $deleted_at * @property int $user_id * @property int $from_currency_id * @property int $to_currency_id - * @property \Illuminate\Support\Carbon $date + * @property Carbon $date * @property string $rate * @property string|null $user_rate * @property-read TransactionCurrency $fromCurrency diff --git a/app/Models/LinkType.php b/app/Models/LinkType.php index 970e8549c2..df91a6fcfa 100644 --- a/app/Models/LinkType.php +++ b/app/Models/LinkType.php @@ -22,21 +22,22 @@ declare(strict_types=1); namespace FireflyIII\Models; -use Carbon\Carbon; use Eloquent; use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Query\Builder; +use Illuminate\Support\Carbon; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; + /** * FireflyIII\Models\LinkType * * @property int $id - * @property \Illuminate\Support\Carbon|null $created_at - * @property \Illuminate\Support\Carbon|null $updated_at - * @property \Illuminate\Support\Carbon|null $deleted_at + * @property Carbon|null $created_at + * @property Carbon|null $updated_at + * @property Carbon|null $deleted_at * @property string $name * @property string $outward * @property string $inward @@ -63,6 +64,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class LinkType extends Model { use SoftDeletes; + /** * The attributes that should be casted to native types. * @@ -84,14 +86,14 @@ class LinkType extends Model * * @param string $value * - * @throws NotFoundHttpException * @return LinkType * + * @throws NotFoundHttpException */ public static function routeBinder(string $value): LinkType { if (auth()->check()) { - $linkTypeId = (int) $value; + $linkTypeId = (int)$value; $linkType = self::find($linkTypeId); if (null !== $linkType) { return $linkType; diff --git a/app/Models/Location.php b/app/Models/Location.php index 3afecf48e1..7dbc62105b 100644 --- a/app/Models/Location.php +++ b/app/Models/Location.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Models; + use Eloquent; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Collection; @@ -30,6 +31,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Database\Eloquent\Relations\MorphTo; use Illuminate\Support\Carbon; + /** * FireflyIII\Models\Location * diff --git a/app/Models/ObjectGroup.php b/app/Models/ObjectGroup.php index f107c19f93..cd14db695a 100644 --- a/app/Models/ObjectGroup.php +++ b/app/Models/ObjectGroup.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Models; + use Eloquent; use FireflyIII\User; use Illuminate\Database\Eloquent\Builder; @@ -32,6 +33,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\MorphToMany; use Illuminate\Support\Carbon; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; + /** * FireflyIII\Models\ObjectGroup * @@ -63,8 +65,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; */ class ObjectGroup extends Model { - protected $fillable = ['title', 'order', 'user_id']; - /** * The attributes that should be casted to native types. * @@ -77,13 +77,36 @@ class ObjectGroup extends Model 'user_id' => 'integer', 'deleted_at' => 'datetime', ]; + protected $fillable = ['title', 'order', 'user_id']; + + /** + * Route binder. Converts the key in the URL to the specified object (or throw 404). + * + * @param string $value + * + * @return ObjectGroup + * @throws NotFoundHttpException + */ + public static function routeBinder(string $value): ObjectGroup + { + if (auth()->check()) { + $objectGroupId = (int)$value; + /** @var ObjectGroup $objectGroup */ + $objectGroup = self::where('object_groups.id', $objectGroupId) + ->where('object_groups.user_id', auth()->user()->id)->first(); + if (null !== $objectGroup) { + return $objectGroup; + } + } + throw new NotFoundHttpException; + } /** * @return MorphToMany */ - public function piggyBanks() + public function accounts() { - return $this->morphedByMany(PiggyBank::class, 'object_groupable'); + return $this->morphedByMany(Account::class, 'object_groupable'); } /** @@ -97,31 +120,9 @@ class ObjectGroup extends Model /** * @return MorphToMany */ - public function accounts() + public function piggyBanks() { - return $this->morphedByMany(Account::class, 'object_groupable'); - } - - /** - * Route binder. Converts the key in the URL to the specified object (or throw 404). - * - * @param string $value - * - * @throws NotFoundHttpException - * @return ObjectGroup - */ - public static function routeBinder(string $value): ObjectGroup - { - if (auth()->check()) { - $objectGroupId = (int) $value; - /** @var ObjectGroup $objectGroup */ - $objectGroup = self::where('object_groups.id', $objectGroupId) - ->where('object_groups.user_id', auth()->user()->id)->first(); - if (null !== $objectGroup) { - return $objectGroup; - } - } - throw new NotFoundHttpException; + return $this->morphedByMany(PiggyBank::class, 'object_groupable'); } /** diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.php index 1e92fa0bb7..028b37cab0 100644 --- a/app/Models/PiggyBank.php +++ b/app/Models/PiggyBank.php @@ -22,7 +22,6 @@ declare(strict_types=1); namespace FireflyIII\Models; -use Carbon\Carbon; use Eloquent; use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; @@ -31,19 +30,21 @@ use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Query\Builder; +use Illuminate\Support\Carbon; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; + /** * FireflyIII\Models\PiggyBank * - * @property int $id - * @property \Illuminate\Support\Carbon|null $created_at - * @property \Illuminate\Support\Carbon|null $updated_at - * @property \Illuminate\Support\Carbon|null $deleted_at + * @property int $id + * @property Carbon|null $created_at + * @property Carbon|null $updated_at + * @property Carbon|null $deleted_at * @property int $account_id * @property string $name * @property string $targetamount - * @property \Illuminate\Support\Carbon|null $startdate - * @property \Illuminate\Support\Carbon|null $targetdate + * @property Carbon|null $startdate + * @property Carbon|null $targetdate * @property int $order * @property bool $active * @property bool $encrypted @@ -108,13 +109,13 @@ class PiggyBank extends Model * * @param string $value * - * @throws NotFoundHttpException * @return PiggyBank + * @throws NotFoundHttpException */ public static function routeBinder(string $value): PiggyBank { if (auth()->check()) { - $piggyBankId = (int) $value; + $piggyBankId = (int)$value; $piggyBank = self::where('piggy_banks.id', $piggyBankId) ->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id') ->where('accounts.user_id', auth()->user()->id)->first(['piggy_banks.*']); @@ -125,23 +126,6 @@ class PiggyBank extends Model throw new NotFoundHttpException; } - /** - * Get all of the tags for the post. - */ - public function objectGroups() - { - return $this->morphToMany(ObjectGroup::class, 'object_groupable'); - } - - /** - * @codeCoverageIgnore - * @return MorphMany - */ - public function attachments(): MorphMany - { - return $this->morphMany(Attachment::class, 'attachable'); - } - /** * @codeCoverageIgnore * @return BelongsTo @@ -151,6 +135,15 @@ class PiggyBank extends Model return $this->belongsTo(Account::class); } + /** + * @codeCoverageIgnore + * @return MorphMany + */ + public function attachments(): MorphMany + { + return $this->morphMany(Attachment::class, 'attachable'); + } + /** * @codeCoverageIgnore * Get all of the piggy bank's notes. @@ -160,6 +153,14 @@ class PiggyBank extends Model return $this->morphMany(Note::class, 'noteable'); } + /** + * Get all of the tags for the post. + */ + public function objectGroups() + { + return $this->morphToMany(ObjectGroup::class, 'object_groupable'); + } + /** * @codeCoverageIgnore * @return HasMany @@ -185,6 +186,6 @@ class PiggyBank extends Model */ public function setTargetamountAttribute($value): void { - $this->attributes['targetamount'] = (string) $value; + $this->attributes['targetamount'] = (string)$value; } } diff --git a/app/Models/PiggyBankEvent.php b/app/Models/PiggyBankEvent.php index 85c96c5641..480a8819bc 100644 --- a/app/Models/PiggyBankEvent.php +++ b/app/Models/PiggyBankEvent.php @@ -22,20 +22,21 @@ declare(strict_types=1); namespace FireflyIII\Models; -use Carbon\Carbon; use Eloquent; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Support\Carbon; + /** * FireflyIII\Models\PiggyBankEvent * * @property int $id - * @property \Illuminate\Support\Carbon|null $created_at - * @property \Illuminate\Support\Carbon|null $updated_at + * @property Carbon|null $created_at + * @property Carbon|null $updated_at * @property int $piggy_bank_id * @property int|null $transaction_journal_id - * @property \Illuminate\Support\Carbon $date + * @property Carbon $date * @property string $amount * @property PiggyBank $piggyBank * @property-read TransactionJournal|null $transactionJournal @@ -85,7 +86,7 @@ class PiggyBankEvent extends Model */ public function setAmountAttribute($value): void { - $this->attributes['amount'] = (string) $value; + $this->attributes['amount'] = (string)$value; } /** diff --git a/app/Models/PiggyBankRepetition.php b/app/Models/PiggyBankRepetition.php index de87bac9c1..839c15cf99 100644 --- a/app/Models/PiggyBankRepetition.php +++ b/app/Models/PiggyBankRepetition.php @@ -31,14 +31,14 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; /** * FireflyIII\Models\PiggyBankRepetition * - * @property int $id + * @property int $id * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at - * @property int $piggy_bank_id + * @property int $piggy_bank_id * @property \Illuminate\Support\Carbon|null $startdate * @property \Illuminate\Support\Carbon|null $targetdate - * @property string $currentamount - * @property-read PiggyBank $piggyBank + * @property string $currentamount + * @property-read PiggyBank $piggyBank * @method static EloquentBuilder|PiggyBankRepetition newModelQuery() * @method static EloquentBuilder|PiggyBankRepetition newQuery() * @method static EloquentBuilder|PiggyBankRepetition onDates(Carbon $start, Carbon $target) @@ -124,6 +124,6 @@ class PiggyBankRepetition extends Model */ public function setCurrentamountAttribute($value): void { - $this->attributes['currentamount'] = (string) $value; + $this->attributes['currentamount'] = (string)$value; } } diff --git a/app/Models/Preference.php b/app/Models/Preference.php index 83f7801074..d743f360ad 100644 --- a/app/Models/Preference.php +++ b/app/Models/Preference.php @@ -33,13 +33,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * FireflyIII\Models\Preference * - * @property int $id - * @property Carbon|null $created_at - * @property Carbon|null $updated_at - * @property int $user_id - * @property string $name - * @property int|string|array|null $data - * @property-read User $user + * @property int $id + * @property Carbon|null $created_at + * @property Carbon|null $updated_at + * @property int $user_id + * @property string $name + * @property int|string|array|null $data + * @property-read User $user * @method static Builder|Preference newModelQuery() * @method static Builder|Preference newQuery() * @method static Builder|Preference query() diff --git a/app/Models/Recurrence.php b/app/Models/Recurrence.php index b62e3f758c..ff2e99a395 100644 --- a/app/Models/Recurrence.php +++ b/app/Models/Recurrence.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace FireflyIII\Models; + use Eloquent; use FireflyIII\User; use Illuminate\Database\Eloquent\Collection; @@ -37,10 +38,10 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * FireflyIII\Models\Recurrence * - * @property int $id - * @property Carbon|null $created_at - * @property Carbon|null $updated_at - * @property Carbon|null $deleted_at + * @property int $id + * @property Carbon|null $created_at + * @property Carbon|null $updated_at + * @property Carbon|null $deleted_at * @property int $user_id * @property int $transaction_type_id * @property string $title @@ -89,6 +90,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class Recurrence extends Model { use SoftDeletes; + /** * The attributes that should be casted to native types. * @@ -120,13 +122,13 @@ class Recurrence extends Model * * @param string $value * - * @throws NotFoundHttpException * @return Recurrence + * @throws NotFoundHttpException */ public static function routeBinder(string $value): Recurrence { if (auth()->check()) { - $recurrenceId = (int) $value; + $recurrenceId = (int)$value; /** @var User $user */ $user = auth()->user(); /** @var Recurrence $recurrence */ @@ -138,6 +140,15 @@ class Recurrence extends Model throw new NotFoundHttpException; } + /** + * @codeCoverageIgnore + * @return MorphMany + */ + public function attachments(): MorphMany + { + return $this->morphMany(Attachment::class, 'attachable'); + } + /** * @codeCoverageIgnore * Get all of the notes. @@ -183,15 +194,6 @@ class Recurrence extends Model return $this->belongsTo(TransactionCurrency::class); } - /** - * @codeCoverageIgnore - * @return MorphMany - */ - public function attachments(): MorphMany - { - return $this->morphMany(Attachment::class, 'attachable'); - } - /** * @codeCoverageIgnore * @return BelongsTo diff --git a/app/Models/RecurrenceMeta.php b/app/Models/RecurrenceMeta.php index 63e0727d93..5b40c521f8 100644 --- a/app/Models/RecurrenceMeta.php +++ b/app/Models/RecurrenceMeta.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace FireflyIII\Models; + use Eloquent; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -58,6 +59,7 @@ use Illuminate\Support\Carbon; class RecurrenceMeta extends Model { use SoftDeletes; + /** * The attributes that should be casted to native types. * diff --git a/app/Models/RecurrenceRepetition.php b/app/Models/RecurrenceRepetition.php index f029de6b8d..f3b88354a4 100644 --- a/app/Models/RecurrenceRepetition.php +++ b/app/Models/RecurrenceRepetition.php @@ -22,20 +22,21 @@ declare(strict_types=1); namespace FireflyIII\Models; -use Carbon\Carbon; + use Eloquent; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Query\Builder; +use Illuminate\Support\Carbon; /** * FireflyIII\Models\RecurrenceRepetition * * @property int $id - * @property \Illuminate\Support\Carbon|null $created_at - * @property \Illuminate\Support\Carbon|null $updated_at - * @property \Illuminate\Support\Carbon|null $deleted_at + * @property Carbon|null $created_at + * @property Carbon|null $updated_at + * @property Carbon|null $deleted_at * @property int $recurrence_id * @property string $repetition_type * @property string $repetition_moment @@ -70,6 +71,7 @@ class RecurrenceRepetition extends Model /** @var int */ public const WEEKEND_TO_MONDAY = 4; use SoftDeletes; + /** * The attributes that should be casted to native types. * diff --git a/app/Models/RecurrenceTransaction.php b/app/Models/RecurrenceTransaction.php index bd27e8713d..49118d0c40 100644 --- a/app/Models/RecurrenceTransaction.php +++ b/app/Models/RecurrenceTransaction.php @@ -22,20 +22,21 @@ declare(strict_types=1); namespace FireflyIII\Models; + use Eloquent; +use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Query\Builder; use Illuminate\Support\Carbon; -use Illuminate\Support\Collection; /** * FireflyIII\Models\RecurrenceTransaction * - * @property int $id - * @property Carbon|null $created_at + * @property int $id + * @property Carbon|null $created_at * @property Carbon|null $updated_at * @property Carbon|null $deleted_at * @property int $recurrence_id @@ -49,7 +50,7 @@ use Illuminate\Support\Collection; * @property-read Account $destinationAccount * @property-read TransactionCurrency|null $foreignCurrency * @property-read Recurrence $recurrence - * @property-read \Illuminate\Database\Eloquent\Collection|RecurrenceTransactionMeta[] $recurrenceTransactionMeta + * @property-read Collection|RecurrenceTransactionMeta[] $recurrenceTransactionMeta * @property-read int|null $recurrence_transaction_meta_count * @property-read Account $sourceAccount * @property-read TransactionCurrency $transactionCurrency @@ -79,6 +80,7 @@ use Illuminate\Support\Collection; class RecurrenceTransaction extends Model { use SoftDeletes; + /** * The attributes that should be casted to native types. * @@ -153,6 +155,7 @@ class RecurrenceTransaction extends Model { return $this->belongsTo(TransactionCurrency::class); } + /** * @codeCoverageIgnore * @return BelongsTo diff --git a/app/Models/RecurrenceTransactionMeta.php b/app/Models/RecurrenceTransactionMeta.php index d7de97ac91..df7846f4ed 100644 --- a/app/Models/RecurrenceTransactionMeta.php +++ b/app/Models/RecurrenceTransactionMeta.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace FireflyIII\Models; + use Eloquent; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -58,6 +59,7 @@ use Illuminate\Support\Carbon; class RecurrenceTransactionMeta extends Model { use SoftDeletes; + /** * The attributes that should be casted to native types. * diff --git a/app/Models/Rule.php b/app/Models/Rule.php index 9d9b8e413f..4d37bd6f9f 100644 --- a/app/Models/Rule.php +++ b/app/Models/Rule.php @@ -36,25 +36,25 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * FireflyIII\Models\Rule * - * @property int $id - * @property Carbon|null $created_at - * @property Carbon|null $updated_at - * @property Carbon|null $deleted_at - * @property int $user_id - * @property int $rule_group_id - * @property string $title - * @property string|null $description - * @property int $order - * @property bool $active - * @property bool $stop_processing - * @property bool $strict - * @property-read string $action_value - * @property-read Collection|RuleAction[] $ruleActions - * @property-read int|null $rule_actions_count - * @property-read RuleGroup $ruleGroup - * @property Collection|RuleTrigger[] $ruleTriggers - * @property-read int|null $rule_triggers_count - * @property-read User $user + * @property int $id + * @property Carbon|null $created_at + * @property Carbon|null $updated_at + * @property Carbon|null $deleted_at + * @property int $user_id + * @property int $rule_group_id + * @property string $title + * @property string|null $description + * @property int $order + * @property bool $active + * @property bool $stop_processing + * @property bool $strict + * @property-read string $action_value + * @property-read Collection|RuleAction[] $ruleActions + * @property-read int|null $rule_actions_count + * @property-read RuleGroup $ruleGroup + * @property Collection|RuleTrigger[] $ruleTriggers + * @property-read int|null $rule_triggers_count + * @property-read User $user * @method static \Illuminate\Database\Eloquent\Builder|Rule newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|Rule newQuery() * @method static Builder|Rule onlyTrashed() diff --git a/app/Models/RuleAction.php b/app/Models/RuleAction.php index 874064b92f..a4a2932fe2 100644 --- a/app/Models/RuleAction.php +++ b/app/Models/RuleAction.php @@ -22,18 +22,18 @@ declare(strict_types=1); namespace FireflyIII\Models; -use Carbon\Carbon; use Eloquent; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Support\Carbon; /** * FireflyIII\Models\RuleAction * * @property int $id - * @property \Illuminate\Support\Carbon|null $created_at - * @property \Illuminate\Support\Carbon|null $updated_at + * @property Carbon|null $created_at + * @property Carbon|null $updated_at * @property int $rule_id * @property string $action_type * @property string $action_value diff --git a/app/Models/RuleGroup.php b/app/Models/RuleGroup.php index 36412c08e3..04aa7b4108 100644 --- a/app/Models/RuleGroup.php +++ b/app/Models/RuleGroup.php @@ -22,30 +22,31 @@ declare(strict_types=1); namespace FireflyIII\Models; -use Carbon\Carbon; use Eloquent; use FireflyIII\User; +use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Query\Builder; -use Illuminate\Support\Collection; +use Illuminate\Support\Carbon; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; + /** * FireflyIII\Models\RuleGroup * * @property int $id - * @property \Illuminate\Support\Carbon|null $created_at - * @property \Illuminate\Support\Carbon|null $updated_at - * @property \Illuminate\Support\Carbon|null $deleted_at + * @property Carbon|null $created_at + * @property Carbon|null $updated_at + * @property Carbon|null $deleted_at * @property int $user_id * @property string $title * @property string|null $description * @property int $order * @property bool $active * @property bool $stop_processing - * @property \Illuminate\Database\Eloquent\Collection|Rule[] $rules + * @property Collection|Rule[] $rules * @property-read int|null $rules_count * @property-read User $user * @method static \Illuminate\Database\Eloquent\Builder|RuleGroup newModelQuery() @@ -69,6 +70,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class RuleGroup extends Model { use SoftDeletes; + /** * The attributes that should be casted to native types. * @@ -92,13 +94,13 @@ class RuleGroup extends Model * * @param string $value * - * @throws NotFoundHttpException * @return RuleGroup + * @throws NotFoundHttpException */ public static function routeBinder(string $value): RuleGroup { if (auth()->check()) { - $ruleGroupId = (int) $value; + $ruleGroupId = (int)$value; /** @var User $user */ $user = auth()->user(); /** @var RuleGroup $ruleGroup */ diff --git a/app/Models/RuleTrigger.php b/app/Models/RuleTrigger.php index 33219e9df1..07153a1109 100644 --- a/app/Models/RuleTrigger.php +++ b/app/Models/RuleTrigger.php @@ -22,18 +22,18 @@ declare(strict_types=1); namespace FireflyIII\Models; -use Carbon\Carbon; use Eloquent; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Support\Carbon; /** * FireflyIII\Models\RuleTrigger * * @property int $id - * @property \Illuminate\Support\Carbon|null $created_at - * @property \Illuminate\Support\Carbon|null $updated_at + * @property Carbon|null $created_at + * @property Carbon|null $updated_at * @property int $rule_id * @property string $trigger_type * @property string $trigger_value diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index b20f7b47d2..5cfaeaf6a8 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -35,33 +35,33 @@ use Illuminate\Database\Eloquent\SoftDeletes; /** * FireflyIII\Models\Transaction * - * @property int $id - * @property \Illuminate\Support\Carbon|null $created_at - * @property \Illuminate\Support\Carbon|null $updated_at - * @property \Illuminate\Support\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 $modified - * @property string $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 \FireflyIII\Models\Account $account - * @property-read Collection|\FireflyIII\Models\Budget[] $budgets - * @property-read int|null $budgets_count - * @property-read Collection|\FireflyIII\Models\Category[] $categories - * @property-read int|null $categories_count - * @property-read \FireflyIII\Models\TransactionCurrency|null $foreignCurrency - * @property-read \FireflyIII\Models\TransactionCurrency|null $transactionCurrency - * @property-read \FireflyIII\Models\TransactionJournal $transactionJournal - * @method static Builder|Transaction after(\Carbon\Carbon $date) - * @method static Builder|Transaction before(\Carbon\Carbon $date) + * @property int $id + * @property \Illuminate\Support\Carbon|null $created_at + * @property \Illuminate\Support\Carbon|null $updated_at + * @property \Illuminate\Support\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 $modified + * @property string $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() * @method static \Illuminate\Database\Query\Builder|Transaction onlyTrashed() @@ -83,11 +83,12 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @method static \Illuminate\Database\Query\Builder|Transaction withTrashed() * @method static \Illuminate\Database\Query\Builder|Transaction withoutTrashed() * @mixin Eloquent - * @property int $the_count + * @property int $the_count */ class Transaction extends Model { use SoftDeletes, HasFactory; + /** * The attributes that should be casted to native types. * @@ -110,30 +111,6 @@ class Transaction extends Model /** @var array Hidden from view */ protected $hidden = ['encrypted']; - /** - * Check if a table is joined. - * - * @param Builder $query - * @param string $table - * - * @return bool - * @codeCoverageIgnore - */ - public static function isJoined(Builder $query, string $table): bool - { - $joins = $query->getQuery()->joins; - if (null === $joins) { - return false; - } - foreach ($joins as $join) { - if ($join->table === $table) { - return true; - } - } - - return false; - } - /** * Get the account this object belongs to. * @@ -194,6 +171,30 @@ class Transaction extends Model $query->where('transaction_journals.date', '>=', $date->format('Y-m-d 00:00:00')); } + /** + * Check if a table is joined. + * + * @param Builder $query + * @param string $table + * + * @return bool + * @codeCoverageIgnore + */ + public static function isJoined(Builder $query, string $table): bool + { + $joins = $query->getQuery()->joins; + if (null === $joins) { + return false; + } + foreach ($joins as $join) { + if ($join->table === $table) { + return true; + } + } + + return false; + } + /** * Check for transactions BEFORE the specified date. * @@ -235,7 +236,7 @@ class Transaction extends Model */ public function setAmountAttribute($value): void { - $this->attributes['amount'] = (string) $value; + $this->attributes['amount'] = (string)$value; } /** diff --git a/app/Models/TransactionCurrency.php b/app/Models/TransactionCurrency.php index 0476b97324..ec3018c4a4 100644 --- a/app/Models/TransactionCurrency.php +++ b/app/Models/TransactionCurrency.php @@ -22,21 +22,22 @@ declare(strict_types=1); namespace FireflyIII\Models; -use Carbon\Carbon; use Eloquent; use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Query\Builder; +use Illuminate\Support\Carbon; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; + /** * FireflyIII\Models\TransactionCurrency * * @property int $id - * @property \Illuminate\Support\Carbon|null $created_at - * @property \Illuminate\Support\Carbon|null $updated_at - * @property \Illuminate\Support\Carbon|null $deleted_at + * @property Carbon|null $created_at + * @property Carbon|null $updated_at + * @property Carbon|null $deleted_at * @property bool $enabled * @property string $code * @property string $name @@ -90,13 +91,13 @@ class TransactionCurrency extends Model * * @param string $value * - * @throws NotFoundHttpException * @return TransactionCurrency + * @throws NotFoundHttpException */ public static function routeBinder(string $value): TransactionCurrency { if (auth()->check()) { - $currencyId = (int) $value; + $currencyId = (int)$value; $currency = self::find($currencyId); if (null !== $currency) { return $currency; diff --git a/app/Models/TransactionGroup.php b/app/Models/TransactionGroup.php index 31200938ba..53cdb3a815 100644 --- a/app/Models/TransactionGroup.php +++ b/app/Models/TransactionGroup.php @@ -32,6 +32,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Query\Builder; use Illuminate\Support\Carbon; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; + /** * FireflyIII\Models\TransactionGroup * @@ -85,13 +86,13 @@ class TransactionGroup extends Model * * @param string $value * - * @throws NotFoundHttpException * @return TransactionGroup + * @throws NotFoundHttpException */ public static function routeBinder(string $value): TransactionGroup { if (auth()->check()) { - $groupId = (int) $value; + $groupId = (int)$value; /** @var User $user */ $user = auth()->user(); /** @var TransactionGroup $group */ diff --git a/app/Models/TransactionJournalLink.php b/app/Models/TransactionJournalLink.php index 3ba5cd69b5..f38091319e 100644 --- a/app/Models/TransactionJournalLink.php +++ b/app/Models/TransactionJournalLink.php @@ -22,21 +22,21 @@ declare(strict_types=1); namespace FireflyIII\Models; -use Carbon\Carbon; use Eloquent; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\MorphMany; +use Illuminate\Support\Carbon; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * FireflyIII\Models\TransactionJournalLink * * @property int $id - * @property \Illuminate\Support\Carbon|null $created_at - * @property \Illuminate\Support\Carbon|null $updated_at + * @property Carbon|null $created_at + * @property Carbon|null $updated_at * @property int $link_type_id * @property int $source_id * @property int $destination_id @@ -80,14 +80,14 @@ class TransactionJournalLink extends Model * * @param string $value * - * @throws NotFoundHttpException * @return TransactionJournalLink * + * @throws NotFoundHttpException */ public static function routeBinder(string $value): TransactionJournalLink { 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') diff --git a/app/Models/TransactionJournalMeta.php b/app/Models/TransactionJournalMeta.php index f0c0ee3125..94a9feba64 100644 --- a/app/Models/TransactionJournalMeta.php +++ b/app/Models/TransactionJournalMeta.php @@ -60,6 +60,7 @@ use Illuminate\Support\Carbon; class TransactionJournalMeta extends Model { use SoftDeletes; + /** * The attributes that should be casted to native types. * diff --git a/app/Models/Webhook.php b/app/Models/Webhook.php index 368d0f28e9..05d6781e43 100644 --- a/app/Models/Webhook.php +++ b/app/Models/Webhook.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace FireflyIII\Models; + use Eloquent; use FireflyIII\User; use Illuminate\Database\Eloquent\Builder; @@ -36,7 +37,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * FireflyIII\Models\Webhook * - * @property int $id + * @property int $id * @property Carbon|null $created_at * @property Carbon|null $updated_at * @property Carbon|null $deleted_at @@ -66,8 +67,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @method static \Illuminate\Database\Query\Builder|Webhook withTrashed() * @method static \Illuminate\Database\Query\Builder|Webhook withoutTrashed() * @mixin Eloquent - * @property string $title - * @property string $secret + * @property string $title + * @property string $secret * @method static Builder|Webhook whereSecret($value) * @method static Builder|Webhook whereTitle($value) */ @@ -88,9 +89,6 @@ class Webhook extends Model // delivery public const DELIVERY_JSON = 300; - - protected $fillable = ['active', 'trigger', 'response', 'delivery', 'user_id', 'url', 'title', 'secret']; - protected $casts = [ 'active' => 'boolean', @@ -98,6 +96,7 @@ class Webhook extends Model 'response' => 'integer', 'delivery' => 'integer', ]; + protected $fillable = ['active', 'trigger', 'response', 'delivery', 'user_id', 'url', 'title', 'secret']; /** * Route binder. Converts the key in the URL to the specified object (or throw 404). diff --git a/app/Models/WebhookAttempt.php b/app/Models/WebhookAttempt.php index 7b0316a9f2..5397402480 100644 --- a/app/Models/WebhookAttempt.php +++ b/app/Models/WebhookAttempt.php @@ -64,15 +64,6 @@ class WebhookAttempt extends Model { use SoftDeletes; - /** - * @codeCoverageIgnore - * @return BelongsTo - */ - public function webhookMessage(): BelongsTo - { - return $this->belongsTo(WebhookMessage::class); - } - /** * Route binder. Converts the key in the URL to the specified object (or throw 404). * @@ -95,4 +86,13 @@ class WebhookAttempt extends Model } throw new NotFoundHttpException; } + + /** + * @codeCoverageIgnore + * @return BelongsTo + */ + public function webhookMessage(): BelongsTo + { + return $this->belongsTo(WebhookMessage::class); + } } diff --git a/app/Models/WebhookMessage.php b/app/Models/WebhookMessage.php index 6de37badd0..23d5b5cb93 100644 --- a/app/Models/WebhookMessage.php +++ b/app/Models/WebhookMessage.php @@ -36,7 +36,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * FireflyIII\Models\WebhookMessage * - * @property int $id + * @property int $id * @property Carbon|null $created_at * @property Carbon|null $updated_at * @property string|null $deleted_at