Evaluate.php 1.0 KB
<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/5/7
 * Time: 14:29
 */

namespace app\index\model;


use think\Model;

class Evaluate extends Model
{
    public function getThumbnailAttr($value){
        $images = [];
        if(!empty($value)){
            $images = explode(',',$value);
            foreach($images as $key => $image){
                $images[$key] = cdnurl($image);
            }
        }
        return $images;
    }
    public function getCreatetimeAttr($value){
        return date('Y-m-d H:i:s',$value);
    }
    public function countData($where){
        $where['status'] = ['eq','1'];
        $data = $this->where($where)->count();
        return $data;
    }
    public function selectData($where){
        $where['status'] = ['eq','1'];
        $data = $this->where($where)->order('createtime desc')->select();
        $userModel = new User();
        foreach($data as $key => $vo){
            $data[$key]['user'] = $userModel->findData(['id'=>$vo['user_id']]);
        }
        return $data;
    }
}