Почему не выводит уведомление для пользователя 12, открыл браузер и вошел под ним,но ничего нет
в логе
Pusher : State changed : connecting -> connected with new socket ID 127854.10730967
pusher.min.js:8 Pusher : Event sent : {"event":"pusher:subscribe","data":{"channel":"my-channel"}}
pusher.min.js:8 Pusher : Event recd : {"event":"pusher_internal:subscription_succeeded","channel":"my-channel","data":{}}
pusher.min.js:8 Pusher : No callbacks on my-channel for pusher:subscription_succeeded
вызываю событие
event(new UserNotification(User::where('id','=', 12)->first(), 'Вас лайкнули'));
само событие
namespace App\Events;
use App\User;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class UserNotification implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
* Create a new event instance.
*
* @return void
*/
/**
* @var User
*/
public $user;
/**
* @var array
*/
public $data;
/**
* Create a new event instance.
* @param array $data
*/
public function __construct(User $user, $data)
{
$this->user = $user;
$this->data = $data;
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return ['my-channel'];
}
public function broadcastAs()
{
return 'my-event';
}
}
и вставил код
<script src="https://js.pusher.com/5.0/pusher.min.js"></script>
<script>
// Enable pusher logging - don't include this in production
Pusher.logToConsole = true;
var pusher = new Pusher('122121212', {
cluster: 'eu',
forceTLS: true
});
var channel = pusher.subscribe('my-channel');
channel.bind('my-event', function(data) {
alert(JSON.stringify(data));
});
</script>