<?php
/*
 * @Author: taowj 965042433@qq.com
 * @Date: 2023-07-14 16:34:36
 * @LastEditors: taowj 965042433@qq.com
 * @LastEditTime: 2023-07-21 11:06:05
 * @FilePath: \zhupu\application\admin\model\worship\Worshipgoodsmodel.php
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

namespace app\admin\model\worship;

use think\Model;


class Worshipgoodsmodel extends Model
{





    // 表名
    protected $name = 'worship_goods';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'create_time_text'
    ];


    public function getStatusList()
    {
        return ['0' => __('Closed 0'), '1' => __('Closed 1')];
    }



    public function getCreateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }

    protected function setCreateTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }
    /**
     * 单个数据查询
     */
    public static function dataInfo($where)
    {
        return  self::where($where)->find();
    }
    /**
     * 批量查询列表
     */
    public static function dataList($where, $page, $limit, $order = "id DESC")
    {
        $data = self::where($where)->page($page)->limit($limit)->order($order)->select();
        return $data;
    }
}
