Add attributes

This commit is contained in:
James Cole
2023-01-02 06:44:52 +01:00
parent 3c1f44f554
commit 0429f50e5c
3 changed files with 67 additions and 13 deletions

View File

@@ -25,6 +25,7 @@ namespace FireflyIII\Models;
use Eloquent;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Carbon;
@@ -99,4 +100,24 @@ class CurrencyExchangeRate extends Model
{
return $this->belongsTo(User::class);
}
/**
* @return Attribute
*/
protected function rate(): Attribute
{
return Attribute::make(
get: fn($value) => (string) $value,
);
}
/**
* @return Attribute
*/
protected function userRate(): Attribute
{
return Attribute::make(
get: fn($value) => (string) $value,
);
}
}