HasOneProduct.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace addons\TinyShop\common\traits;
  3. use addons\TinyShop\common\models\product\Product;
  4. /**
  5. * Trait HasOneProduct
  6. * @package addons\TinyShop\common\traits
  7. */
  8. trait HasOneProduct
  9. {
  10. /**
  11. * 关联商品
  12. *
  13. * @return \yii\db\ActiveQuery
  14. */
  15. public function getProduct()
  16. {
  17. return $this->hasOne(Product::class, ['id' => 'product_id'])->select([
  18. 'id',
  19. 'merchant_id',
  20. 'name',
  21. 'sketch',
  22. 'keywords',
  23. 'picture',
  24. 'view',
  25. 'match_point',
  26. 'price',
  27. 'market_price',
  28. 'cost_price',
  29. 'stock',
  30. 'total_sales',
  31. 'shipping_type',
  32. 'delivery_type',
  33. 'is_member_discount',
  34. 'member_discount_type',
  35. 'is_sales_visible',
  36. 'is_stock_visible',
  37. 'is_commission',
  38. 'unit',
  39. 'type',
  40. 'stock_deduction_type',
  41. 'min_buy',
  42. 'max_buy',
  43. 'tags',
  44. 'point_exchange_type',
  45. 'point_give_type',
  46. 'max_use_point',
  47. 'give_point',
  48. 'growth_give_type',
  49. 'give_growth',
  50. 'supplier_id',
  51. 'audit_status',
  52. 'status',
  53. ]);
  54. }
  55. }
粤ICP备19079148号