<?php

namespace App\Modules\Catalogo\Models;

use Illuminate\Database\Eloquent\Model;

class Entidad extends Model
{
	protected $table = 'entidad';
	
	protected $guarded = [];

	protected $fillable = [];

	public function show_all_entidad(){
		try{
			$show = Entidad::with(['departamentos','provincias','identidad_document'])->get();
			return $show;
		} catch (\Exception $e) {
	    	report($e);
        	return false;
	    }
	}
    
	public function show_by_id($id){
			$show = Entidad::with(['departamentos','provincias','distritos','identidad_document'])->where('entidad.id',$id)->get();
			return $show;
	
	}
    
    public function departamentos(){
		return $this->belongsTo('\App\Modules\Utilitarios\Models\Departamento');
	}
	public function provincias(){
		return $this->belongsTo('\App\Modules\Utilitarios\Models\Provincia');
	}
	public function distritos(){
		return $this->belongsTo('\App\Modules\Utilitarios\Models\Distrito');
	}
	public function identidad_document(){
		return $this->belongsTo('\App\Modules\Utilitarios\Models\Identidad_document');
	}
}
