mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 00:27:30 +00:00
Refactor models.
This commit is contained in:
@@ -40,7 +40,7 @@ class TransactionCurrency extends Model
|
||||
public ?bool $userGroupEnabled = null;
|
||||
public ?bool $userGroupNative = null;
|
||||
|
||||
protected $fillable = ['name', 'code', 'symbol', 'decimal_places', 'enabled'];
|
||||
protected $fillable = ['name', 'code', 'symbol', 'decimal_places', 'enabled'];
|
||||
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
@@ -50,7 +50,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());
|
||||
@@ -101,13 +101,6 @@ class TransactionCurrency extends Model
|
||||
return $this->belongsToMany(User::class)->withTimestamps()->withPivot('user_default');
|
||||
}
|
||||
|
||||
protected function decimalPlaces(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn ($value) => (int) $value,
|
||||
);
|
||||
}
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
@@ -118,4 +111,11 @@ class TransactionCurrency extends Model
|
||||
'enabled' => 'bool',
|
||||
];
|
||||
}
|
||||
|
||||
protected function decimalPlaces(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user