IndentModel.php 1.6 KB
<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/6/5
 * Time: 19:56
 */

namespace app\portal\model;


use think\Model;

class IndentModel extends Model
{
    /**
     * 自动转换 支付时间
     * @param $value
     * @return false|string
     */
    public function getPayTimeAttr($value){
        if(!empty($value)){
            return date('Y-m-d H:i:s',$value);
        }
    }
    /**
     * 获取多个订单
     * @param $where
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function selectData($where){
        $data = $this->where($where)->order('create_time desc')->select()->toArray();
        return $data;
    }

    /**
     * 获取单条数据
     * @param $where
     * @return array|false|\PDOStatement|string|Model
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function findData($where){
        $data = $this->where($where)->find();
        return $data;
    }

    /**
     * 更新
     * @param $where
     * @param $data
     * @return IndentModel
     */
    public function updateData($where,$data){
        $result = $this->where($where)->update($data);
        return $result;
    }

    /**
     * 删除订单
     * @param $where
     * @return int
     */
    public function deleteData($where){
        $result = $this->where($where)->delete();
        return $result;
    }
}