laravel-5.6 - Laravel 通知(数据库通知)图标不会改变
问题描述
大家好,如果有来自 github 的推送事件,我尝试为管理员用户发送实时通知以获取通知。
我已经制作了一个通知表并收到通知,问题是通知图标没有改变,并在有新通知时放置 1++,我需要先刷新页面才能更改图标。
这是我的控制器。
public function index(Request $request){
view()->share('page_sub', 'Webhhook');
$data = Cache::store('file')->get('repo');
// dd($data);
return view('pages.admin.system.webhook.index')->with('data',$data);
}
public function handle(Request $request){
// $data = $request;
$admins = User::whereHas('roles', function($q){$q->whereIn('roles.name', ['superadmin']);})->get();
$data = [
'id' => $request['repository']['id'],
'name' => $request['repository']['name'],
'tags_url' => $request['repository']['tags_url'],
'archive_url' => $request['repository']['archive_url'],
'updated_at' => $request['repository']['updated_at'],
];
$now = \Carbon\Carbon::now();
$repo_data = cache('repo');
\Log::info($data);
if ($data['updated_at'] != $repo_data['updated_at']) {
Cache::store('file')->put('repo', $data, $now->addMonth());
}
foreach($admins as $user){
$user->notify(new WebhookNotification($repo_data));
}
}
这是图标所在的我的标题。
<div class="an-notifications" id="notify">
<div class="btn-group an-notifications-dropown notifications" >
@if (count(auth()->user()->unreadNotifications) > 0 )
<button type="button" class="an-btn an-btn-icon dropdown-toggle js-has-new-notification" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id="notif">
<i class="ion-ios-bell-outline"></i>
</button>
@elseif (count(auth()->user()->unreadNotifications) === 0 )
<button type="button" class="an-btn an-btn-icon dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id="notif">
<i class="ion-ios-bell-outline"></i>
</button>
@endif
<div class="dropdown-menu">
<p class="an-info-count">Notifications <span>{{count(auth()->user()->unreadNotifications)}}</span></p>
<div class="an-info-content notifications-info notifications-content">
<ul class="nav">
<li>
@forelse(auth()->user()->unreadNotifications as $notification)
<div class="an-info-single unread" id="notif">
<a href="{{url('iaccs-hook-list')}}">
<span class="icon-container important">
<i class="icon-setting"></i>
</span>
<div class="info-content">
<h5 class="user-name">Update Client</h5>
<p class="content"><i class="icon-clock"></i> {{$notification->created_at}}</p>
</div>
</a>
</div>
@empty
<a href="">No Unread Notification</a>
@endforelse
</li>
</ul>
</div> <!-- end .AN-INFO-CONTENT -->
<div class="an-info-show-all-btn">
<a class="an-btn an-btn-transparent fluid rounded uppercase small-font" href="#">Show all</a>
</div>
</div>
</div>
</div> <!-- end .AN-NOTIFICATION -->
我需要安装 Laravel echo 吗?还是我错过了一些代码?
谢谢你。
解决方案
推荐阅读
- vue.js - vuejs-datepicke 样式在表格中损坏
- javascript - Http调用Node.js问题,socket挂断错误
- command - PowerPoint Mobily 使用命令行打开我的文件
- css - Laravel,如何使用 default.css 发送查看邮件
- python - Pandas 比较两列不同的数据框,如果匹配,则复制第三列的值
- javascript - 将 JSON 数据准备到 JavaScript 数组中以在 react-heatmap-grid React 应用程序中使用
- react-native - 在 React-Native 中,如何使用反应导航从模态屏幕进入 .push() 屏幕?
- javascript - 插入文本后,Quill js编辑器退格失败
- testing - 压力测试和断点测试的区别
- c# - 依赖注入中的 AddScoped