Code cleanup.

This commit is contained in:
James Cole
2023-12-20 19:35:52 +01:00
parent c4f6366642
commit 64ec0cf62e
997 changed files with 12908 additions and 28136 deletions

View File

@@ -42,39 +42,40 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\Bill
*
* @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_currency_id
* @property string $name
* @property string $match
* @property string $amount_min
* @property string $amount_max
* @property Carbon $date
* @property Carbon|null $end_date
* @property Carbon|null $extension_date
* @property string $repeat_freq
* @property int $skip
* @property bool $automatch
* @property bool $active
* @property bool $name_encrypted
* @property bool $match_encrypted
* @property int $order
* @property-read Collection|Attachment[] $attachments
* @property-read int|null $attachments_count
* @property-read Collection|Note[] $notes
* @property-read int|null $notes_count
* @property-read Collection|ObjectGroup[] $objectGroups
* @property-read int|null $object_groups_count
* @property-read TransactionCurrency|null $transactionCurrency
* @property-read Collection|TransactionJournal[] $transactionJournals
* @property-read int|null $transaction_journals_count
* @property-read User $user
* @property int $id
* @property null|Carbon $created_at
* @property null|Carbon $updated_at
* @property null|Carbon $deleted_at
* @property int $user_id
* @property int $transaction_currency_id
* @property string $name
* @property string $match
* @property string $amount_min
* @property string $amount_max
* @property Carbon $date
* @property null|Carbon $end_date
* @property null|Carbon $extension_date
* @property string $repeat_freq
* @property int $skip
* @property bool $automatch
* @property bool $active
* @property bool $name_encrypted
* @property bool $match_encrypted
* @property int $order
* @property Attachment[]|Collection $attachments
* @property null|int $attachments_count
* @property Collection|Note[] $notes
* @property null|int $notes_count
* @property Collection|ObjectGroup[] $objectGroups
* @property null|int $object_groups_count
* @property null|TransactionCurrency $transactionCurrency
* @property Collection|TransactionJournal[] $transactionJournals
* @property null|int $transaction_journals_count
* @property User $user
*
* @method static \Illuminate\Database\Eloquent\Builder|Bill newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Bill newQuery()
* @method static Builder|Bill onlyTrashed()
* @method static Builder|Bill onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|Bill query()
* @method static \Illuminate\Database\Eloquent\Builder|Bill whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|Bill whereAmountMax($value)
@@ -96,10 +97,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static \Illuminate\Database\Eloquent\Builder|Bill whereTransactionCurrencyId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Bill whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Bill whereUserId($value)
* @method static Builder|Bill withTrashed()
* @method static Builder|Bill withoutTrashed()
* @property int $user_group_id
* @method static Builder|Bill withTrashed()
* @method static Builder|Bill withoutTrashed()
*
* @property int $user_group_id
*
* @method static \Illuminate\Database\Eloquent\Builder|Bill whereUserGroupId($value)
*
* @mixin Eloquent
*/
class Bill extends Model
@@ -123,7 +127,6 @@ class Bill extends Model
'match_encrypted' => 'boolean',
];
protected $fillable
= [
'name',
@@ -147,37 +150,31 @@ class Bill extends Model
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
*
* @return Bill
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): self
{
if (auth()->check()) {
$billId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var Bill|null $bill */
/** @var null|Bill $bill */
$bill = $user->bills()->find($billId);
if (null !== $bill) {
return $bill;
}
}
throw new NotFoundHttpException();
}
/**
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* @return MorphMany
*/
public function attachments(): MorphMany
{
return $this->morphMany(Attachment::class, 'attachable');
@@ -200,7 +197,6 @@ class Bill extends Model
}
/**
*
* @param mixed $value
*/
public function setAmountMaxAttribute($value): void
@@ -210,25 +206,17 @@ class Bill extends Model
/**
* @param mixed $value
*
*/
public function setAmountMinAttribute($value): void
{
$this->attributes['amount_min'] = (string)$value;
}
/**
* @return BelongsTo
*/
public function transactionCurrency(): BelongsTo
{
return $this->belongsTo(TransactionCurrency::class);
}
/**
* @return HasMany
*/
public function transactionJournals(): HasMany
{
return $this->hasMany(TransactionJournal::class);
@@ -236,59 +224,45 @@ class Bill extends Model
/**
* Get the max amount
*
* @return Attribute
*/
protected function amountMax(): Attribute
{
return Attribute::make(
get: static fn($value) => (string)$value,
get: static fn ($value) => (string)$value,
);
}
/**
* Get the min amount
*
* @return Attribute
*/
protected function amountMin(): Attribute
{
return Attribute::make(
get: static fn($value) => (string)$value,
get: static fn ($value) => (string)$value,
);
}
/**
* @return Attribute
*/
protected function order(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
/**
* Get the skip
*
* @return Attribute
*/
protected function skip(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
/**
* @return Attribute
*/
protected function transactionCurrencyId(): Attribute
{
return Attribute::make(
get: static fn($value) => (int)$value,
get: static fn ($value) => (int)$value,
);
}
}