refactor: kb & station & terminal
This commit is contained in:
@@ -50,11 +50,28 @@ class User extends Authenticatable
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户所属的所有分组
|
||||
* 获取用户关联的线站
|
||||
*/
|
||||
public function groups(): BelongsToMany
|
||||
public function stations(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Group::class);
|
||||
return $this->belongsToMany(Station::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户可访问的线站 IDs
|
||||
* 空数组表示无限制(管理员)
|
||||
*/
|
||||
public function getAccessibleStationIds(): array
|
||||
{
|
||||
return $this->stations()->pluck('stations.id')->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户是否受线站限制
|
||||
*/
|
||||
public function hasStationRestriction(): bool
|
||||
{
|
||||
return $this->stations()->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user