You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
932 B
PHTML

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Support\Carbon;
class PaylaterCustomer extends Model
{
protected $fillable = [
'limit',
'usage',
'description',
'customer_id',
'day_deadline',
1 year ago
'day_deadline_at',
];
1 year ago
protected $appends = [
'paylater_description'
];
1 year ago
public function customer()
{
return $this->hasOne(Customer::class, 'customer_id', 'id');
}
public function paylaterDescription(): Attribute
{
return Attribute::make(get: function () {
if ($this->day_deadline_at != null) {
$deadlineAt = Carbon::parse($this->day_deadline_at)->translatedFormat('d F Y');
return "lunasi pinjaman kamu sebelum jatuh tempo pada {$deadlineAt}";
}
return "yuk gunakan terus saldo yang tersedia";
});
}
}