<?php

namespace App\Models;

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

class Pendatang extends Model
{
    use HasFactory;

    protected $table = 'pendatang';

    protected $fillable = [
        'penduduk_id',
        'anggota_kk_id',
        'tujuan_datang',
        'alasan_datang',
        'tanggal_datang',
    ];
    
    public function anggotaKeluarga(): BelongsTo
    {
        return $this->belongsTo(AnggotaKartuKeluarga::class, 'anggota_kk_id');
    }

    public function penduduk(): BelongsTo
    {
        return $this->belongsTo(Penduduk::class);
    }
}