Files
amb_wechatapp/application/admin/model/course/Group.php
T

59 lines
1.1 KiB
PHP

<?php
namespace app\admin\model\course;
use think\Model;
class Group extends Model
{
// 表名
protected $name = 'course_group';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
'status_text'
];
/**
* 状态列表
*/
public function getStatusList()
{
return [
0 => '禁用',
1 => '启用'
];
}
/**
* 状态文本
*/
public function getStatusTextAttr($value, $data)
{
$list = $this->getStatusList();
return isset($list[$data['status']]) ? $list[$data['status']] : '';
}
/**
* 获取排序
*/
public function defineSort()
{
$maxItem = self::field("sort")->where('uniacid', UNIACID)->order("sort desc")->find();
if (!$maxItem) {
return 0;
}
return $maxItem['sort'] + 1;
}
}