chore: 重写初始提交(清空历史,整理后全量提交)
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2026-2036 http://ywxapp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: ywxapp<admin@ywxapp.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace ywxapp\model;
|
||||
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
use ywxapp\model\BaseModel;
|
||||
/**
|
||||
* MemberGroup 类
|
||||
*
|
||||
* @author ywxapp <admin@ywxapp.cn>
|
||||
*/
|
||||
class MemberGroup extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
'strict' => false,
|
||||
'name' => 'member_group',
|
||||
'autoWriteTimestamp' => 'int',
|
||||
'createTime' => 'create_at',
|
||||
'updateTime' => 'update_at',
|
||||
'deleteTime' => 'delete_at',
|
||||
'defaultSoftDelete' => 0,
|
||||
// 'dateFormat' => 'Y-m-d H:i:s',
|
||||
'append' => [],
|
||||
'hidden' => ['create_at', 'update_at', 'delete_at'],
|
||||
'readonly' => ['id'],
|
||||
];
|
||||
}
|
||||
// 角色拥有的用户
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->belongsToMany(MemberUser::class, MemberGroupAccess::class, 'uid', 'gid');
|
||||
}
|
||||
|
||||
// 角色拥有的权限
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return $this->belongsToMany(MemberRule::class, GroupRule::class, 'rid', 'gid');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 表结构自愈:建表 + 关键列兜底(install.sql 为事实源)。
|
||||
* 查询/写入前调用,避免老库缺表导致 1146。
|
||||
*/
|
||||
public static function ensureSchema(): void
|
||||
{
|
||||
BaseModel::ensureTableFromInstall(BaseModel::currentPrefix(), 'member_group');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user