<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

use App\Traits\ModelLogChanging;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * 留存：目前仅当作区级使用 后续将省市表并入此表
 */
class Region extends Model
{
    use ModelLogChanging;
    use SoftDeletes;

    public $timestamps=false;
    protected $fillable = ["parent_id","name","type","code"];

    const type=[
        1 => "省",
        2 => "市",
        3 => "区县",
    ];

    public function parent()
    {   //父级
        return $this->belongsTo(Region::class,"parent_id","id");
    }

    public function city()
    {   //市
        return $this->belongsTo(City::class,"parent_id","id");
    }
}
