<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class VillageModel extends Model
{

    protected $table = "village";
    protected $primaryKey = 'village_id';
    public function commune(){
        return CommuneModel::find($this->commune_id);
    }
    public function district(){
        return DistrictModel::find($this->commune()->district_id);
    }
    public function province(){
        return ProvinceModel::find($this->district()->province_id);
    }
    public function address($house_no=null,$street_no=null){
        if(!empty($house_no)) $house_no ="ផ្ទះលេខ".$house_no;
        if(!empty($street_no)) $street_no = " ផ្លូវលេខ".$street_no;
        return $house_no.$street_no.' ភូមិ​ '.$this->village_km.' ឃុំ/សង្កាត់ '.$this->commune()->commune_km.' ស្រុក/ខណ្ឌ '.$this->district()->district_km.' ខេត្ត/រាជធានី '.$this->province()->province_km;
    }
}
