// +---------------------------------------------------------------------- declare (strict_types=1); namespace app\common\model\card; use cores\BaseModel; /** * 兑换卡打印模型 * Class CardPrint * @package app\common\model\card */ class CardPrint extends BaseModel { // 定义表名 protected $name = 'card_print'; // 定义主键 protected $pk = 'print_id'; protected $updateTime = false; /** * 关联兑换卡表 * @return \think\model\relation\BelongsTo */ public function card() { $module = self::getCalledModule(); return $this->belongsTo("app\\{$module}\\model\\Card"); } /** * 获取器:下载时间 * @param $value * @return string */ public function getDownloadTimeAttr($value) { return format_time($value); } /** * 新增记录 * @param array $data */ public static function add(array $data) { $model = new static; $model->save($data); } /** * 充值卡打印详情 * @param $where * @param array $with * @return static|null * @throws \think\exception\DbException */ public static function detail($where, $with = []) { !is_array($where) && $where = ['print_id' => (int)$where]; return static::get($where, $with); } }