TaoLer/app/admin/model/AuthRule.php
2021-12-15 15:46:04 +08:00

45 lines
802 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\admin\model;
use think\Model;
use think\model\concern\SoftDelete;
class AuthRule extends Model
{
//软删除
use SoftDelete;
protected $deleteTime = 'delete_time';
protected $defaultSoftDelete = 0;
public function searchIdAttr($query, $value, $data)
{
$query->where('id', $value );
}
/**
* 权限树
*/
public function authRuleTree()
{
$authRules = $this->order('sort asc')->select();
//return $this->sort($authRules);
return $authRules;
}
/**
* idpid,菜单排序
* @var $data 数据
* @var $pid 父级id
*/
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;
}
}