quanwei
18 hours ago c441dea81bd86bdfb12dff35821fed51f4cc91c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
 
namespace app\operations\model\auth;
 
use app\common\model\plus\operations\User as UserModel;
use app\common\model\plus\operations\UserRole as UserRoleModel;
 
/**
 * 区域代理用户模型
 */
class User extends UserModel
{
    /**
     * 获取管理员列表
     */
    public function getList($limit = 20)
    {
        return $this->with(['roles.role'])->where('is_delete', '=', 0)
            ->order(['create_time' => 'desc'])
            ->paginate($limit);
    }
 
    /**
     * 检查用户名是否已存在
     */
    public function getUserName($where, $operations_user_id = 0)
    {
        if ($operations_user_id > 0) {
            return $this->where($where)->where('operations_user_id', '<>', $operations_user_id)->count();
        }
        return $this->where($where)->count();
    }
 
    /**
     * 删除管理员
     */
    public function del($where)
    {
        self::update(['is_delete' => 1], $where);
        return UserRoleModel::where('operations_user_id', $where['operations_user_id'])->delete();
    }
}