Region.php 711 B

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