TaoLer/app/admin/model/AuthRule.php

45 lines
802 B
PHP
Raw Normal View History

2020-01-01 13:17:19 +08:00
<?php
namespace app\admin\model;
use think\Model;
2020-01-14 15:47:11 +08:00
use think\model\concern\SoftDelete;
2020-01-01 13:17:19 +08:00
class AuthRule extends Model
{
//软删除
2020-01-14 15:47:11 +08:00
use SoftDelete;
protected $deleteTime = 'delete_time';
protected $defaultSoftDelete = 0;
2020-01-01 13:17:19 +08:00
2020-01-14 15:47:11 +08:00
public function searchIdAttr($query, $value, $data)
{
$query->where('id', $value );
}
2021-12-15 15:46:04 +08:00
/**
* 权限树
*/
2020-01-01 13:17:19 +08:00
public function authRuleTree()
{
$authRules = $this->order('sort asc')->select();
2021-12-15 15:46:04 +08:00
//return $this->sort($authRules);
return $authRules;
2020-01-01 13:17:19 +08:00
}
2021-12-15 15:46:04 +08:00
/**
* idpid,菜单排序
* @var $data 数据
* @var $pid 父级id
*/
2020-01-01 13:17:19 +08:00
public function sort($data,$pid=0)
{
static $arr = array();
foreach($data as $k=> $v){
if($v['pid']==$pid){
$arr[] = $v;
$this->sort($data,$v['id']);
}
}
return $arr;
}
}