app/Http/Controllers/ProductController.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,ProductModel $productM)
    {
        $param = [];
        $tmp = $request->all();
        if(isset($tmp['bncode']) && !empty($tmp['bncode'])) $param[] =  ['bncode', 'like', '%'.$tmp['bncode'].'%'];
        if(isset($tmp['cas']) && !empty($tmp['cas'])) $param[] =  ['cas', 'like', '%'.$tmp['cas'].'%'];
        if(isset($tmp['product_cname']) && !empty($tmp['product_cname'])) $param[] =  ['product_cname', 'like', '%'.$tmp['product_cname'].'%'];
        $dataObj = $productM::getProducts(['id','cfnum','bncode','cas','product_ename','product_cname'],$param);
        $total = $dataObj->count();
        $result = [
            'respCode' =>'000',
            'total'=> $total,
            'data'=>($total>0)?$dataObj->toArray():[],
            'param' => $param,
            "thead"=>[
                "cfnum"=>"CF编号",
                "bncode"=>"批号",
                "cas"=>"C.A.S",
                "product_cname"=>"中文名称",
                "product_ename"=>"英文名称",
                "op"=>"操作",
              ],
            "class"=>[
                "cfnum"=>"",
                "bncode"=>"",
                "cas"=>"",
                "product_cname"=>"",
                "product_ename"=>"",
                "op"=>"op",
            ]
        ];
        return $this->returnData($result);
    }
public function index ( Request $ request , ProductModel $ productM ) { $ param = [ ] ; $ tmp = $ request -> all ( ) ; if ( isset ( $ tmp [ 'bncode' ] ) && ! empty ( $ tmp [ 'bncode' ] ) ) $ param [ ] = [ 'bncode' , 'like' , '%' . $ tmp [ 'bncode' ] . '%' ] ; if ( isset ( $ tmp [ 'cas' ] ) && ! empty ( $ tmp [ 'cas' ] ) ) $ param [ ] = [ 'cas' , 'like' , '%' . $ tmp [ 'cas' ] . '%' ] ; if ( isset ( $ tmp [ 'product_cname' ] ) && ! empty ( $ tmp [ 'product_cname' ] ) ) $ param [ ] = [ 'product_cname' , 'like' , '%' . $ tmp [ 'product_cname' ] . '%' ] ; $ dataObj = $ productM :: getProducts ( [ 'id' , 'cfnum' , 'bncode' , 'cas' , 'product_ename' , 'product_cname' ] , $ param ) ; $ total = $ dataObj -> count ( ) ; $ result = [ 'respCode' => '000' , 'total' => $ total , 'data' => ( $ total > 0 ) ? $ dataObj -> toArray ( ) : [ ] , 'param' => $ param , " thead " => [ " cfnum " => " CF编号", " bncode " => " 批号", " cas " => " C.A.S " , " product_cname " => " 中文名称", " product_ename " => " 英文名称", " op " => " 操作", ] , " class " => [ " cfnum " => " " , " bncode " => " " , " cas " => " " , " product_cname " => " " , " product_ename " => " " , " op " => " op " , ] ] ; return $ this -> returnData ( $ result ) ; }
Display a listing of the resource.
Display a listing of the resource .
//