ShippingTemplateFree.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\common\model\store\shipping;
  3. use app\common\model\BaseModel;
  4. use app\common\repositories\store\CityAreaRepository;
  5. class ShippingTemplateFree extends BaseModel
  6. {
  7. /**
  8. * Author:Qinii
  9. * Date: 2020/5/6
  10. * Time: 14:20
  11. * @return string
  12. */
  13. public static function tablePk(): string
  14. {
  15. return 'shipping_template_free_id';
  16. }
  17. /**
  18. * Author:Qinii
  19. * Date: 2020/5/6
  20. * Time: 14:20
  21. * @return string
  22. */
  23. public static function tableName(): string
  24. {
  25. return 'shipping_template_free';
  26. }
  27. public function getCityIDsAttr($value, $data)
  28. {
  29. if (!$data['city_id']) return [];
  30. $city_id = explode('/', trim($data['city_id'],'/'));
  31. $data = app()->make(CityAreaRepository::class)->search([])->where('id','in',$city_id)->select();
  32. $result = [];
  33. foreach ($data as $v) {
  34. $result[] = array_map('intval', explode('/', trim($v['path'] . $v['id'], '/')));
  35. }
  36. return $result;
  37. }
  38. public function setCityIdAttr($value)
  39. {
  40. return implode('/',$value);
  41. }
  42. }