You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
813 B

5 years ago
5 years ago
  1. <?php
  2. namespace App\Model\v3;
  3. use App\Model\Model;
  4. class Market extends Model
  5. {
  6. protected $table = 'lanzu_market';
  7. protected $appends = [
  8. 'province_name',
  9. 'city_name',
  10. 'region_name'
  11. ];
  12. public function getProvinceNameAttribute()
  13. {
  14. $area = Area::query()->find($this->attributes['province_id']);
  15. return $area->name ?? '';
  16. }
  17. public function getCityNameAttribute()
  18. {
  19. $area = Area::query()->find($this->attributes['city_id']);
  20. return $area->name ?? '';
  21. }
  22. public function getRegionNameAttribute()
  23. {
  24. $area = Area::query()->find($this->attributes['region_id']);
  25. return $area->name ?? '';
  26. }
  27. public function stores()
  28. {
  29. return $this->hasMany(Store::class,'market_id','id');
  30. }
  31. }