<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class MustahikHistory extends Model
{
    use HasFactory;

    protected $table = 'MustahikHistory';
    protected $primaryKey = 'id_history';

    protected $fillable = [
        'id_mustahik',
        'tahun',
        'nama_mustahik',
        'no_hp',
        'tgl_lahir',
        'pekerjaan_saat_itu',
        'pendapatan_bulanan',
        'status_kepemilikan_rumah',
        'status_kondisi_warga',
        'kategori_asnaf',
        'status_approval',
        'catatan_amil',
        'diupdate_oleh',
        'tanggal_update'
    ];

    // Relasi ke DataMustahik
    public function mustahik()
    {
        return $this->belongsTo(DataMustahik::class, 'id_mustahik', 'id_mustahik');
    }

    // Relasi ke User
    public function petugas()
    {
        return $this->belongsTo(User::class, 'diupdate_oleh', 'id_user');
    }
}