家政小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ProductOrder.php 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Models;
  3. /**
  4. * Class ProductOrder
  5. * @package App\Models
  6. * 产品订单
  7. */
  8. class ProductOrder extends Order
  9. {
  10. function __construct() {
  11. parent::__construct("产品", "产品", "product_order");
  12. $fillable = [
  13. 'product_id', // 产品名称
  14. 'product_name', // 产品信息
  15. 'color', // 产品颜色款色
  16. 'unit', // 产品单格
  17. 'amount', // 产品数量
  18. 'remark', // 买家备注
  19. 'info', // 卖家信息
  20. ];
  21. parent::mergeFillable(parent::getFillable(), $fillable);
  22. }
  23. /**
  24. * 订单里面有多个products
  25. * @return \Illuminate\Database\Eloquent\Relations\HasMany
  26. */
  27. public function products()
  28. {
  29. return $this->belongsToMany('App\Models\Product', 'orders_products_mapping','order_id', 'product_id')
  30. //->using('App\Models\OrdersProductsMapping')
  31. ->withPivot('product_name', 'product_color', 'product_price', 'product_amount', 'product_photo');
  32. }
  33. }