belongsTo('production', 'product_unit','id'); } function unitsTest() { return $this->belongsTo('unitsTest', 'units_id', 'id'); } public function selectSampleListByTaskIdAndUid($where,$pageNum=1,$pageSize=null) { $cyd = (new Cyd()); $data = $cyd->with(['Production', 'UnitsTest'])->where($where)->page($pageNum,$pageSize)->select(); return $data; } public function countSampleListByTaskIdAndUid($where) { $cyd = (new Cyd()); $count = $cyd->with(['Production', 'UnitsTest'])->where($where)->count(); return $count; } //用于生成抽样单编号的,意义不明确 public function countSampleCreateID() { return $this->whereDay('createtime','today')->count(); } }