<?php

namespace App\Models;

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

class Kelahiran extends Model
{
    use HasFactory;

    protected $table = 'kelahiran';

    protected $fillable = [
        'penduduk_id',
        'anggota_kk_id',
    ];

    /**
     * Get the anggotaKeluarga that owns the Kelahiran
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function anggotaKeluarga(): BelongsTo
    {
        return $this->belongsTo(AnggotaKartuKeluarga::class, 'anggota_kk_id');
    }

    /**
     * Get the penduduk that owns the Kelahiran (new relation)
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function penduduk(): BelongsTo
    {
        return $this->belongsTo(Penduduk::class);
    }
}