created_at)->locale('id')->translatedFormat('d F Y'); }); } public function formatCreatedAt(): Attribute { return Attribute::make(get: function () { return Carbon::parse($this->created_at)->locale('id')->translatedFormat('d F Y H:i:s'); }); } public function amount(): Attribute { return Attribute::make(get: function () { if ($this->credit == 0) { return number_format($this->debit, is_float($this->debit) ? 2 : 0, ',', '.'); } return number_format($this->credit, is_float($this->credit) ? 2 : 0, ',', '.'); }); } public function customer() { return $this->belongsTo(Customer::class); } public function update_customer_balance() { $customer = Customer::find($this->customer_id); $customer->update(['poin_balance' => $customer->poin_balance + $this->debit - $this->credit]); } }