SamplePesticides.php 851 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\api\model;
  3. use think\Model;
  4. class SamplePesticides extends Model
  5. {
  6. public function saveItem($data)
  7. {
  8. return parent::saveAll($data);
  9. }
  10. public function getItemByTestIdAndSampleId($test_id, $sample_id)
  11. {
  12. return $this->where([
  13. ['test_id', '=', $test_id],
  14. ['sample_id', '=', $sample_id]
  15. ])
  16. ->failException(false)
  17. ->find();
  18. }
  19. public function getItemBySampleId($sample_id)
  20. {
  21. return $this->where('sample_id', '=', $sample_id)->select();
  22. }
  23. public function saveItemByTestIdAndSampleId($test_id, $sample_id,$data)
  24. {
  25. return $this->where([
  26. ['test_id', '=', $test_id],
  27. ['sample_id', '=', $sample_id]
  28. ])
  29. ->failException(false)
  30. ->save($data);
  31. }
  32. }