*/ protected $fillable = [ 'invoice_id', 'paid_amount', 'status', 'payment_method', 'payment_date', ]; /** * The attributes that are appended with attribute getters. * * @var string[] */ protected $appends = [ 'date', 'localized_state' ]; /** * Get the payment state as translated string. */ public function getLocalizedStateAttribute(): string { return __('invoice.Payment state ' . $this->status); } /** * Get the payment date as localized string. */ public function getDateAttribute(): string { return Date::createFromFormat('Y-m-d', $this->payment_date)->format('d.m.Y'); } /** * Get the invoice the payment belongs to. */ public function invoice(): BelongsTo { return $this->belongsTo(Invoice::class)->with(['customer']); } }