update user and roles model
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Model;
|
namespace App\Model;
|
||||||
|
|
||||||
|
use Hyperf\Database\Model\Relations\BelongsToMany;
|
||||||
use Hyperf\Database\Model\Relations\HasMany;
|
use Hyperf\Database\Model\Relations\HasMany;
|
||||||
use Hyperf\DbConnection\Model\Model;
|
use Hyperf\DbConnection\Model\Model;
|
||||||
|
|
||||||
@@ -38,4 +39,20 @@ class Role extends Model
|
|||||||
{
|
{
|
||||||
return $this->hasMany(User::class, 'role_id');
|
return $this->hasMany(User::class, 'role_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色授权的路由分组
|
||||||
|
*/
|
||||||
|
public function routeGroups(): BelongsToMany
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(RouteGroup::class, 'role_route_groups', 'role_id', 'group_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色的路由覆盖规则
|
||||||
|
*/
|
||||||
|
public function routeOverrides(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(RoleRouteOverride::class, 'role_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,6 +152,14 @@ class User extends Model implements Authenticatable
|
|||||||
return $this->hasMany(Platform::class, 'developer_id');
|
return $this->hasMany(Platform::class, 'developer_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户的数据访问范围
|
||||||
|
*/
|
||||||
|
public function dataScopes(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(UserDataScope::class, 'user_id');
|
||||||
|
}
|
||||||
|
|
||||||
// @TODO 重新实现删除用户时平台归属转移逻辑(Hyperf 不支持 static::deleting 事件绑定)
|
// @TODO 重新实现删除用户时平台归属转移逻辑(Hyperf 不支持 static::deleting 事件绑定)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user