<?php

namespace App\Models;

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

class Pindah extends Model
{
    use HasFactory;

    protected $table = 'pindah';

    protected $fillable = [
        'penduduk_id',
        'tanggal_pindah',
        'alamat_sebelumnya',
        'alasan',
    ];

    protected $casts = [
        'tanggal_pindah' => 'date',
    ];

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