Region.php 644 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use App\Traits\LogModelChanging;
  5. /**
  6. * 留存:目前仅当作区级使用 后续将省市表并入此表
  7. */
  8. class Region extends Model
  9. {
  10. use LogModelChanging;
  11. public $timestamps=false;
  12. protected $fillable = ["parent_id","name","type","code"];
  13. const type=[
  14. 1 => "省",
  15. 2 => "市",
  16. 3 => "区县",
  17. ];
  18. public function parent()
  19. { //父级
  20. return $this->belongsTo(Region::class,"parent_id","id");
  21. }
  22. public function city()
  23. { //市
  24. return $this->belongsTo(City::class,"parent_id","id");
  25. }
  26. }