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 );
|
|
|
|
}
|
2020-01-01 13:17:19 +08:00
|
|
|
//登陆校验
|
|
|
|
public function authRuleTree()
|
|
|
|
{
|
|
|
|
$authRules = $this->order('sort asc')->select();
|
|
|
|
return $this->sort($authRules);
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|