ShippingTemplateRegion.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * @package merchant
  4. * Author: Qinii
  5. * Date: 2020/5/6
  6. * Time: 14:19
  7. */
  8. namespace app\common\model\store\shipping;
  9. use app\common\model\BaseModel;
  10. use app\common\model\Region;
  11. class ShippingTemplateRegion extends BaseModel
  12. {
  13. /**
  14. * Author:Qinii
  15. * Date: 2020/5/6
  16. * Time: 14:20
  17. * @return string
  18. */
  19. public static function tablePk(): string
  20. {
  21. return 'shipping_template_region_id';
  22. }
  23. /**
  24. * Author:Qinii
  25. * Date: 2020/5/6
  26. * Time: 14:20
  27. * @return string
  28. */
  29. public static function tableName(): string
  30. {
  31. return 'shipping_template_region';
  32. }
  33. public function getCityIDsAttr($value,$data)
  34. {
  35. $city_id = explode('/',$data['city_id']);
  36. $result = [];
  37. if(is_array($city_id)){
  38. foreach ($city_id as $v){
  39. // $result[] = [City::where('city_id',$v)->value('parent_id') ?? 0,intval($v) ];
  40. $result[] = [Region::where('id',$v)->value('pid') ?? 0,intval($v) ];
  41. }
  42. }
  43. return $result;
  44. }
  45. public function setCityIdAttr($value)
  46. {
  47. return '/'.( implode('/',$value)).'/';
  48. }
  49. public function getFirstAttr($value)
  50. {
  51. return set_price_rtrim($value);
  52. }
  53. public function getFirstPriceAttr($value)
  54. {
  55. return set_price_rtrim($value);
  56. }
  57. public function getContinueAttr($value)
  58. {
  59. return set_price_rtrim($value);
  60. }
  61. public function getContinuePriceAttr($value)
  62. {
  63. return set_price_rtrim($value);
  64. }
  65. }