ShippingTemplate.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace app\common\model\store\shipping;
  3. use app\common\model\BaseModel;
  4. class ShippingTemplate extends BaseModel
  5. {
  6. /**
  7. * Author:Qinii
  8. * Date: 2020/5/6
  9. * Time: 14:20
  10. * @return string
  11. */
  12. public static function tablePk(): string
  13. {
  14. return 'shipping_template_id';
  15. }
  16. /**
  17. * Author:Qinii
  18. * Date: 2020/5/6
  19. * Time: 14:20
  20. * @return string
  21. */
  22. public static function tableName(): string
  23. {
  24. return 'shipping_template';
  25. }
  26. /**
  27. * 包邮
  28. * @Author:Qinii
  29. * @Date: 2020/5/6
  30. * @Time: 18:00
  31. * @return \think\model\relation\HasMany
  32. */
  33. public function free()
  34. {
  35. return $this->hasMany(ShippingTemplateFree::class, 'temp_id', 'shipping_template_id');
  36. }
  37. /**
  38. * 配送
  39. * @Author:Qinii
  40. * @Date: 2020/5/6
  41. * @Time: 18:01
  42. * @return \think\model\relation\HasMany
  43. */
  44. public function region()
  45. {
  46. return $this->hasMany(ShippingTemplateRegion::class, 'temp_id', 'shipping_template_id');
  47. }
  48. /**
  49. * @return \think\model\relation\HasOne
  50. * @author zfy
  51. * @day 2020/6/4
  52. */
  53. public function freeAddress()
  54. {
  55. return $this->hasOne(ShippingTemplateFree::class, 'temp_id', 'shipping_template_id');
  56. }
  57. /**
  58. * @return \think\model\relation\HasOne
  59. * @author zfy
  60. * @day 2020/6/4
  61. */
  62. public function regionAddress()
  63. {
  64. return $this->hasOne(ShippingTemplateRegion::class, 'temp_id', 'shipping_template_id');
  65. }
  66. /**
  67. * @Author:Qinii
  68. * @Date: 2020/5/6
  69. * @Time: 18:01
  70. * @return \think\model\relation\HasOne
  71. */
  72. public function undelives()
  73. {
  74. return $this->hasOne(ShippingTemplateUndelivery::class, 'temp_id', 'shipping_template_id');
  75. }
  76. public function searchShippingTemplateIdAttr($query,$value)
  77. {
  78. $query->where('shipping_template_id',$value);
  79. }
  80. }