<?php
namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class RegionModel extends Model
{
	protected $connection = 'order';
	protected $table      = 'lie_region';
	protected $primaryKey = 'region_id';
	public $timestamps    = false;

	// 获取指定类型地址
    public function getRegion($region_type=1)
    {
        $map['region_type'] = $region_type;
        return $this->where($map)->select('region_id', 'parent_id', 'region_name')->get()->toArray();
    }

    // 获取地址名称
    public function getRegionName($region_id)
    {
        if (!$region_id) return null;
        
    	return $this->where('region_id', $region_id)->value('region_name');
    }
    
}