QuoteProduct.php 989 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace addons\qingdongams\model;
  3. use think\Db;
  4. use think\Exception;
  5. use think\Model;
  6. use traits\model\SoftDelete;
  7. /**
  8. *报价单产品
  9. */
  10. class QuoteProduct Extends Model {
  11. protected $name = 'qingdongams_quote_product';
  12. // 开启自动写入时间戳字段
  13. protected $autoWriteTimestamp = false;
  14. public function getConfigAttr($value)
  15. {
  16. return json_decode($value,true);
  17. }
  18. //产品
  19. public function product() {
  20. return $this->belongsTo(Product::class, 'product_id', 'id')
  21. ->with('productType')
  22. ->field('id,name,img,num,unit,price as unit_price,description,type_id')
  23. ->bind('name,img,num,unit,unit_price,description,product_type');
  24. }
  25. //产品详情
  26. public function productinfo(){
  27. return $this->belongsTo(Product::class,'product_id','id')
  28. ->field('id,goods_id,name,type,unit,price,cost_price')->with(['goods']);
  29. }
  30. }