feat: 任命/撤销通知系统 + 用户名片UI优化
- 任命/撤销事件增加 type 字段区分类型 - 任命:全屏礼花 + 紫色弹窗 + 紫色系统消息 - 撤销:灰色弹窗 + 灰色系统消息,无礼花 - 消息分发:操作者/被操作者显示在私聊面板,其他人显示在公屏 - 系统消息加随机鼓励语(各5条轮换) - ChatStateService 修复 Redis key 前缀扫描问题(getAllActiveRoomIds) - 用户名片折叠优化:管理员视野、职务履历均可折叠 - 管理操作 + 职务操作合并为「🔧 管理操作」折叠区 - 悄悄话改为「🎁 送礼物」按钮,礼物面板内联展开
This commit is contained in:
@@ -15,6 +15,8 @@ namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
@@ -144,4 +146,38 @@ class User extends Authenticatable
|
||||
|
||||
return $this->vipLevel?->icon ?? '';
|
||||
}
|
||||
|
||||
// ── 职务相关关联 ──────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* 全部猎务履历(包括历史记录)
|
||||
*/
|
||||
public function positions(): HasMany
|
||||
{
|
||||
return $this->hasMany(UserPosition::class)->with(['position.department'])->orderByDesc('appointed_at');
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前在职职务记录(HasOne,最多一条)
|
||||
*/
|
||||
public function activePosition(): HasOne
|
||||
{
|
||||
return $this->hasOne(UserPosition::class)->where('is_active', true)->with(['position.department']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 该用户在职期间的权限操作日志
|
||||
*/
|
||||
public function authorityLogs(): HasMany
|
||||
{
|
||||
return $this->hasMany(PositionAuthorityLog::class)->orderByDesc('created_at');
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断用户是否有当前在职职务
|
||||
*/
|
||||
public function hasActivePosition(): bool
|
||||
{
|
||||
return $this->activePosition()->exists();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user