会员权益项目
This commit is contained in:
@@ -32,6 +32,11 @@ class Level extends Model
|
||||
protected $updateTime = 'updatetime';
|
||||
protected $deleteTime = false;
|
||||
|
||||
protected $type = [
|
||||
'benefits_project' => 'json',
|
||||
];
|
||||
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
'status_text'
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
<?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\member;
|
||||
|
||||
use think\Model;
|
||||
|
||||
|
||||
class MemberBenefitsProject extends Model
|
||||
{
|
||||
// 表名
|
||||
protected $name = 'wdsxh_member_benefits_project';
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = false;
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'created_at';
|
||||
protected $updateTime = 'updated_at';
|
||||
protected $deleteTime = false;
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
'disabled_text'
|
||||
];
|
||||
|
||||
|
||||
protected static function init()
|
||||
{
|
||||
self::afterInsert(function ($row) {
|
||||
$pk = $row->getPk();
|
||||
$row->getQuery()->where($pk, $row[$pk])->update(['sort' => $row[$pk]]);
|
||||
});
|
||||
}
|
||||
|
||||
public function getDisabledList()
|
||||
{
|
||||
return ['0' => __('Member Benefits Project Enabled'), '1' => __('Member Benefits Project Disabled')];
|
||||
}
|
||||
|
||||
|
||||
public function getDisabledTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ? $value : (isset($data['disabled']) ? $data['disabled'] : '');
|
||||
$list = $this->getDisabledList();
|
||||
return isset($list[$value]) ? $list[$value] : '';
|
||||
}
|
||||
|
||||
public function getSimpleByStatus($disabled = 0, $join_config_id = null)
|
||||
{
|
||||
return Self::field(['id', 'name'])->where(function($query) use ($disabled, $join_config_id) {
|
||||
if (null !== $disabled) {
|
||||
$query->where('disabled', '=', $disabled);
|
||||
}
|
||||
if (null !== $join_config_id) {
|
||||
$query->where('join_config_id', '=', $join_config_id);
|
||||
}
|
||||
})->order('sort', 'asc')->select();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user