app/Http/Controllers/TestController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index(Request $request,TestModel $testM,ProductModel $productM)
    {
        $tmp = $request->all();
        $param = [
            ['test_time', '>', $tmp['startDate'].' 00:00:00'],
            ['test_time', '<=', $tmp['endDate'].' 00:00:00'],
        ];
        if(!empty($tmp['cfnum'])) $param[] = ['cfnum', '=', $tmp['cfnum']];
              ;
        if(!empty($tmp['cas'])) $param[] = ['cas', '=', $tmp['cas']];
              ;
        if(!empty($tmp['product_cname'])) $param[] = ['product_cname', 'like', '%'.$tmp['product_cname'].'%'];
              ;     
        if(!empty($tmp['bncode'])) $param[] =  ['tests.bncode', 'like', '%'.$tmp['bncode'].'%'];
        $dataObj = $testM::getTests(['tests.id as id','tests.bncode as bncode','cas','cfnum','nmr','hplc','water','weather','appearance','purity','condition','spectrogram','test_time'],$param);
        var_dump($dataObj->toArray());
        $total = $dataObj->count();
        $result = [
            'respCode' =>'000',
            'total'=> $total,
            'data'=>($total>0)?$dataObj->toArray():[],
            'param' => $param,
            "thead"=>[
                "test_time"=>"测试时间",
                "bncode"=>"批次",
                "cfnum"=>"CF编号",
                "cas"=>"C.A.S",
                "product_cname"=>"中文名称",
                 "product_ename"=>"英文名称",
                "spectrogram"=>"谱图",
                "op"=>"操作",
              ],
            "class"=>[
                "test_time"=>"",
                "bncode"=>"",
                "cfnum"=>"",
                "cas"=>"",
                "product_cname"=>"",
                 "product_ename"=>"",
                "spectrogram"=>"img",
                "op"=>"op",
            ]
        ];
        return $this->returnData($result);
    }
public function index ( Request $ request , TestModel $ testM , ProductModel $ productM ) { $ tmp = $ request -> all ( ) ; $ param = [ [ 'test_time' , '>' , $ tmp [ 'startDate' ] . ' 00:00:00' ] , [ 'test_time' , '<=' , $ tmp [ 'endDate' ] . ' 00:00:00' ] , ] ; if ( ! empty ( $ tmp [ 'cfnum' ] ) ) $ param [ ] = [ 'cfnum' , '=' , $ tmp [ 'cfnum' ] ] ; ; if ( ! empty ( $ tmp [ 'cas' ] ) ) $ param [ ] = [ 'cas' , '=' , $ tmp [ 'cas' ] ] ; ; if ( ! empty ( $ tmp [ 'product_cname' ] ) ) $ param [ ] = [ 'product_cname' , 'like' , '%' . $ tmp [ 'product_cname' ] . '%' ] ; ; if ( ! empty ( $ tmp [ 'bncode' ] ) ) $ param [ ] = [ 'tests.bncode' , 'like' , '%' . $ tmp [ 'bncode' ] . '%' ] ; $ dataObj = $ testM :: getTests ( [ 'tests.id as id' , 'tests.bncode as bncode' , 'cas' , 'cfnum' , 'nmr' , 'hplc' , 'water' , 'weather' , 'appearance' , 'purity' , 'condition' , 'spectrogram' , 'test_time' ] , $ param ) ; $ total = $ dataObj -> count ( ) ; $ result = [ 'respCode' => '000' , 'total' => $ total , 'data' => ( $ total > 0 ) ? $ dataObj -> toArray ( ) : [ ] , 'param' => $ param , " thead " => [ " test_time " => " 测试时间", " bncode " => " 批次", " cfnum " => " CF编号", " cas " => " C.A.S " , " product_cname " => " 中文名称", " spectrogram " => " 谱图", " op " => " 操作", ] , " class " => [ " test_time " => " " , " bncode " => " " , " cfnum " => " " , " cas " => " " , " product_cname " => " " , " spectrogram " => " img " , " op " => " op " , ] ] ; return $ this -> returnData ( $ result ) ; }
Display a listing of the resource.
Display a listing of the resource .
// //var_dump($dataObj->toArray()); // "product_ename"=>"英文名称", // "product_ename"=>"",