customer_id); $paylater = $customer->paylater; if ($paylater->day_deadline_at == null) { $paylater->day_deadline_at = now()->addDays($paylater->day_deadline); } $paylater->update([ 'usage' => $paylater->usage + $this->debit - $this->credit, 'day_deadline_at' => $paylater->day_deadline_at, ]); } public function formatHumanCreatedAt(): Attribute { return Attribute::make(get: function () { return Carbon::parse($this->created_at)->translatedFormat('d F Y'); }); } public function formatCreatedAt(): Attribute { return Attribute::make(get: function () { return Carbon::parse($this->created_at)->translatedFormat('d F Y H:i:s'); }); } public function amount(): Attribute { return Attribute::make(get: function () { if ($this->credit == 0) { return 'Rp' . number_format($this->debit, is_float($this->debit) ? 2 : 0, ',', '.'); } return '-Rp' . number_format($this->credit, is_float($this->credit) ? 2 : 0, ',', '.'); }); } }