<?php

namespace app\api\model;

use think\Model;

class SamplePesticides extends Model
{

    public function saveItem($data)
    {
        return parent::saveAll($data);
    }

    public function getItemByTestIdAndSampleId($test_id, $sample_id)
    {
        return $this->where([
            ['test_id', '=', $test_id],
            ['sample_id', '=', $sample_id]
        ])
            ->failException(false)
            ->find();
    }


    public function getItemBySampleId($sample_id)
    {
        return $this->where('sample_id', '=', $sample_id)->select();
    }

    public function saveItemByTestIdAndSampleId($test_id, $sample_id,$data)
    {
        return $this->where([
            ['test_id', '=', $test_id],
            ['sample_id', '=', $sample_id]
        ])
            ->save($data);
    }



    public function updateItemByTestIdAndSampleId($test_id, $sample_id, $data)
    {
        $result= $this->where([
            ['test_id', '=', $test_id],
            ['sample_id', '=', $sample_id]
        ])
            ->update($data);
        return $result;
    }

    public function saveItemById($id, $data)
    {
        return $this->where($id)->save($data);
    }

}