ShopgoodsModel.php 1.1 KB
<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/11/12
 * Time: 17:32
 */

namespace api\index\model;


use think\Model;

class ShopgoodsModel extends Model
{
    public function getContentAttr($value){
        return cmf_replace_content_file_url(htmlspecialchars_decode($value));
    }

    public function getThumbnailAttr($value){
        return cmf_get_image_preview_url($value);
    }

    public function getImagesAttr($value){
        if(!empty($value)){
            $data = explode(',',$value);
            foreach($data as $key => $vo){
                $data[$key] = cmf_get_image_url($vo);
            }
            return $data;
        }
    }

    public function selectData($where,$page,$pageNum){
        $data = $this
            ->where($where)
            ->field('id,shoptype_id,thumbnail,goods_name,price')
            ->order('id desc')
            ->page($page,$pageNum)
            ->select();
        return $data;
    }

    public function findData($where){
        $data = $this->where($where)->find();
        return $data;
    }
}