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.

35 lines
753 B

6 years ago
6 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. return Area::query()->find($this->attributes['province_id'])->value('name');
  15. }
  16. public function getCityNameAttribute()
  17. {
  18. return Area::query()->find($this->attributes['city_id'])->value('name');
  19. }
  20. public function getRegionNameAttribute()
  21. {
  22. return Area::query()->find($this->attributes['region_id'])->value('name');
  23. }
  24. public function stores()
  25. {
  26. return $this->hasMany(Store::class,'market_id','id');
  27. }
  28. }