init commit
This commit is contained in:
90
application/admin/model/wdsxh/business/Business.php
Normal file
90
application/admin/model/wdsxh/business/Business.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 麦沃德科技赋能开发者,助力商协会发展
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2024 www.wdsxh.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\admin\model\wdsxh\business;
|
||||
|
||||
use think\Model;
|
||||
use traits\model\SoftDelete;
|
||||
|
||||
class Business extends Model
|
||||
{
|
||||
|
||||
use SoftDelete;
|
||||
|
||||
|
||||
|
||||
// 表名
|
||||
protected $name = 'wdsxh_business';
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'integer';
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
protected $deleteTime = 'deletetime';
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
'status_text',
|
||||
'state_text'
|
||||
];
|
||||
|
||||
|
||||
protected static function init()
|
||||
{
|
||||
self::afterInsert(function ($row) {
|
||||
$pk = $row->getPk();
|
||||
$row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public function getStatusList()
|
||||
{
|
||||
return ['normal' => __('Status normal'), 'hidden' => __('Status hidden')];
|
||||
}
|
||||
|
||||
public function getStateList()
|
||||
{
|
||||
return ['1' => __('State 1'), '2' => __('State 2'), '3' => __('State 3')];
|
||||
}
|
||||
|
||||
|
||||
public function getStatusTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
|
||||
$list = $this->getStatusList();
|
||||
return isset($list[$value]) ? $list[$value] : '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function getStateTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ? $value : (isset($data['state']) ? $data['state'] : '');
|
||||
$list = $this->getStateList();
|
||||
return isset($list[$value]) ? $list[$value] : '';
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo('app\admin\model\wdsxh\business\Category','category_id','id')->setEagerlyType(0);
|
||||
}
|
||||
public function member()
|
||||
{
|
||||
return $this->belongsTo('app\admin\model\wdsxh\member\Member','member_id','id')->setEagerlyType(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user