小编Row*_*yri的帖子

如何连接两个 Laravel 应用程序?

我有 2 个 laravel (5.2) 应用程序共享同一个数据库。这 2 个应用程序由 2 种不同的用户类型使用。现在我想让它们相互连接,以便当使用第一个应用程序的用户发送请求以将数据保存到特定数据库表时,会向第二个应用程序发送包含此数据的通知。我怎样才能做到这一点 ??

laravel

5
推荐指数
1
解决办法
1978
查看次数

向特定用户发送推送通知-Laravel

在我的laravel应用中,我想使用Pusher向特定用户发送通知。

我将此代码放在我的方法中:

$pusher = App::make('pusher');

$pusher->trigger( 'notification-channel',
                  'notification-event', 
                   array('text' => 'this is a notification'));

return view('home');
Run Code Online (Sandbox Code Playgroud)

并将其放在home.blade.php中:

<script src="//js.pusher.com/3.0/pusher.min.js"></script>
<script>

    var pusher = new Pusher("{{env("PUSHER_KEY")}}");
    var channel = pusher.subscribe('notification-channel');
    channel.bind('notification-event', function(data) {
      alert(data.text);
    });
Run Code Online (Sandbox Code Playgroud)

但这会使通知显示给任何用户。这还存在另一个问题,即用户应该只在主页上才能接收通知!

因此,我该怎么做才能将通知发送给特定用户,并使该用户从任何页面接收该通知?

notifications laravel pusher

2
推荐指数
1
解决办法
3248
查看次数

标签 统计

laravel ×2

notifications ×1

pusher ×1