初始化项目:添加后端代码、ThinkPHP框架、前端资源
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user