You've already forked think-plugs-notice
- 新增 Index 控制器,实现后台首页逻辑- 添加通知模块,展示未读通知数量 - 实现用户资料修改和密码更改功能 - 添加主题切换功能 - 优化登录和权限验证流程 - 新增首页模板和样式
30 lines
602 B
PHP
30 lines
602 B
PHP
<?php
|
|
|
|
namespace jerryyan\notice\model;
|
|
|
|
use think\admin\Model;
|
|
|
|
class NoticeNotice extends Model
|
|
{
|
|
public static function types()
|
|
{
|
|
return static::mk()->group('type')->field('type,count(id) as count')->select();
|
|
}
|
|
|
|
/**
|
|
* 获取当前用户未读通知数量
|
|
* @return int
|
|
*/
|
|
public static function getUnreadCount()
|
|
{
|
|
$userId = session('user.id');
|
|
if (!$userId) {
|
|
return 0;
|
|
}
|
|
|
|
return static::mk()
|
|
->where('staff_id', $userId)
|
|
->whereNull('read_at')
|
|
->count();
|
|
}
|
|
} |