. */ declare(strict_types=1); namespace FireflyIII\Models; use FireflyIII\Support\Models\ReturnsIntegerIdTrait; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; /** * @mixin IdeHelperPiggyBankEvent */ class PiggyBankEvent extends Model { use ReturnsIntegerIdTrait; protected $casts = [ 'created_at' => 'datetime', 'updated_at' => 'datetime', 'date' => 'date', ]; protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'date_tz', 'amount']; protected $hidden = ['amount_encrypted']; public function piggyBank(): BelongsTo { return $this->belongsTo(PiggyBank::class); } /** * @param mixed $value */ public function setAmountAttribute($value): void { $this->attributes['amount'] = (string)$value; } public function transactionJournal(): BelongsTo { return $this->belongsTo(TransactionJournal::class); } /** * Get the amount */ protected function amount(): Attribute { return Attribute::make( get: static fn ($value) => (string)$value, ); } protected function piggyBankId(): Attribute { return Attribute::make( get: static fn ($value) => (int)$value, ); } }