<?php

namespace App\Models;

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

class Community extends Model
{
    use HasFactory;

    public $timestamps = false;
    protected $table = 'tbl_community';
    protected $primaryKey = 'community_id';

    protected $fillable = [
        'member_name', 'member_sh_id', 'father_name', 'member_email',
        'member_phone', 'status', 'dob', 'doj', 'designation',
        'panchayat', 'address', 'jivika_name', 'photo_url',
        'district_id', 'block_id', 'shg_id', 'user_type',
        'created_by', 'report_to', 'created_at', 'updated_by', 'updated_at',
    ];

    public function district()
    {
        return $this->belongsTo(District::class, 'district_id', 'id');
    }

    // user.block → blocks.block_id
    public function block()
    {
        return $this->belongsTo(Block::class, 'block_id', 'block_id');
    }

    public function createdBy()
    {
        return $this->belongsTo(User::class, 'created_by', 'id');
    }
}
