ShippingTemplate.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\common\model\store\shipping;
  12. use app\common\model\BaseModel;
  13. class ShippingTemplate extends BaseModel
  14. {
  15. /**
  16. * Author:Qinii
  17. * Date: 2020/5/6
  18. * Time: 14:20
  19. * @return string
  20. */
  21. public static function tablePk(): string
  22. {
  23. return 'shipping_template_id';
  24. }
  25. /**
  26. * Author:Qinii
  27. * Date: 2020/5/6
  28. * Time: 14:20
  29. * @return string
  30. */
  31. public static function tableName(): string
  32. {
  33. return 'shipping_template';
  34. }
  35. /**
  36. * 包邮
  37. * @Author:Qinii
  38. * @Date: 2020/5/6
  39. * @Time: 18:00
  40. * @return \think\model\relation\HasMany
  41. */
  42. public function free()
  43. {
  44. return $this->hasMany(ShippingTemplateFree::class, 'temp_id', 'shipping_template_id');
  45. }
  46. /**
  47. * 配送
  48. * @Author:Qinii
  49. * @Date: 2020/5/6
  50. * @Time: 18:01
  51. * @return \think\model\relation\HasMany
  52. */
  53. public function region()
  54. {
  55. return $this->hasMany(ShippingTemplateRegion::class, 'temp_id', 'shipping_template_id');
  56. }
  57. /**
  58. * @return \think\model\relation\HasOne
  59. * @author xaboy
  60. * @day 2020/6/4
  61. */
  62. public function freeAddress()
  63. {
  64. return $this->hasOne(ShippingTemplateFree::class, 'temp_id', 'shipping_template_id');
  65. }
  66. /**
  67. * @return \think\model\relation\HasOne
  68. * @author xaboy
  69. * @day 2020/6/4
  70. */
  71. public function regionAddress()
  72. {
  73. return $this->hasOne(ShippingTemplateRegion::class, 'temp_id', 'shipping_template_id');
  74. }
  75. /**
  76. * @Author:Qinii
  77. * @Date: 2020/5/6
  78. * @Time: 18:01
  79. * @return \think\model\relation\HasOne
  80. */
  81. public function undelives()
  82. {
  83. return $this->hasOne(ShippingTemplateUndelivery::class, 'temp_id', 'shipping_template_id');
  84. }
  85. public function searchShippingTemplateIdAttr($query,$value)
  86. {
  87. $query->where('shipping_template_id',$value);
  88. }
  89. }