feat: tambah fitur iuran anggota (MemberDue)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class MemberDue extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'user_id', 'amount', 'period', 'status', 'paid_at', 'notes', 'created_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'paid_at' => 'date',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (MemberDue $due) {
|
||||
$due->created_by ??= auth()->id();
|
||||
});
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user