Cyd.php 970 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. *
  4. *User:Administrator
  5. *Date:2021/10/14
  6. */
  7. namespace app\api\model;
  8. use think\Model;
  9. class Cyd extends Model
  10. {
  11. function production()
  12. {
  13. return $this->belongsTo('production', 'product_unit','id');
  14. }
  15. function unitsTest()
  16. {
  17. return $this->belongsTo('unitsTest', 'units_id', 'id');
  18. }
  19. public function selectSampleListByTaskIdAndUid($where,$pageNum=1,$pageSize=null)
  20. {
  21. $cyd = (new Cyd());
  22. $data = $cyd->with(['Production', 'UnitsTest'])->where($where)->page($pageNum,$pageSize)->select();
  23. return $data;
  24. }
  25. public function countSampleListByTaskIdAndUid($where)
  26. {
  27. $cyd = (new Cyd());
  28. $count = $cyd->with(['Production', 'UnitsTest'])->where($where)->count();
  29. return $count;
  30. }
  31. //用于生成抽样单编号的,意义不明确
  32. public function countSampleCreateID()
  33. {
  34. return $this->whereDay('createtime','today')->count();
  35. }
  36. }