同步操作将从 FastAdmin 开源后台框架/FastAdmin 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<?phpnamespace app\admin\model;use fast\Tree;use think\Model;class UserRule extends Model{// 表名protected $name = 'user_rule';// 自动写入时间戳字段protected $autoWriteTimestamp = 'int';// 定义时间戳字段名protected $createTime = 'createtime';protected $updateTime = 'updatetime';// 追加属性protected $append = ['status_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' => __('Normal'), 'hidden' => __('Hidden')];}public function getStatusTextAttr($value, $data){$value = $value ? $value : $data['status'];$list = $this->getStatusList();return isset($list[$value]) ? $list[$value] : '';}public static function getTreeList($selected = []){$ruleList = collection(self::where('status', 'normal')->order('weigh desc,id desc')->select())->toArray();$nodeList = [];Tree::instance()->init($ruleList);$ruleList = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'name');$hasChildrens = [];foreach ($ruleList as $k => $v){if ($v['haschild'])$hasChildrens[] = $v['id'];}foreach ($ruleList as $k => $v) {$state = array('selected' => in_array($v['id'], $selected) && !in_array($v['id'], $hasChildrens));$nodeList[] = array('id' => $v['id'], 'parent' => $v['pid'] ? $v['pid'] : '#', 'text' => __($v['title']), 'type' => 'menu', 'state' => $state);}return $nodeList;}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。