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.

41 lines
934 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 = [
1 year ago
'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');
1 year ago
return "lunasi pinjaman kamu sebelum jatuh tempo pada {$deadlineAt}";
}
1 year ago
return 'yuk gunakan terus saldo yang tersedia';
});
}
}