Ai_GirlFriend/xunifriend_RaeeC/application/admin/model/girlfriend/Hairstyles.php

60 lines
1.1 KiB
PHP
Raw Normal View History

2026-01-31 19:15:41 +08:00
<?php
namespace app\admin\model\girlfriend;
use think\Model;
use traits\model\SoftDelete;
class Hairstyles extends Model
{
use SoftDelete;
// 表名
protected $name = 'girlfriend_hairstyles';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = 'deletetime';
// 追加属性
protected $append = [
'gender_text'
];
protected static function init()
{
self::afterInsert(function ($row) {
if (!$row['weigh']) {
$pk = $row->getPk();
$row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
}
});
}
public function getGenderList()
{
return ['male' => __('Gender male'), 'female' => __('Gender female')];
}
public function getGenderTextAttr($value, $data)
{
$value = $value ?: ($data['gender'] ?? '');
$list = $this->getGenderList();
return $list[$value] ?? '';
}
}