<?php

namespace App\Models\Pertanian;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Models\Wilayah\DesaKelurahan;
use App\Models\Pertanian\Tanaman;
use App\Models\Profile;

class Lahan extends Model
{
    use SoftDeletes;

    protected $table = 'map_lahan';

    protected $fillable = [
        'nama',
        'status_kepemilikan',
        'profile_id',
        'keluarga_pengelola_id',
        'adat_pemilik_id',
        'desa_kelurahan_id',
        'path',
        'luas_lahan',
        'created_by',
        'updated_by',
        'deleted_by',
    ];

    public function profile()
    {
        return $this->belongsTo(Profile::class, 'profile_id');
    }

    public function desakelurahan()
    {
        return $this->belongsTo(DesaKelurahan::class, 'desa_kelurahan_id');
    }

    public function tanaman()
    {
        return $this->hasMany(Tanaman::class, 'lahan_id');
    }
}
