0

I am trying to trigger a pusher event but it's not working.

class SendWaitingForRedirect implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $message;

    public function __construct($message)
    {
        $this->message = $message;
    }

    public function broadcastOn()
    {
        return ['my-channel'];
    }

    public function broadcastAs()
    {
        return 'my-event';
    }
}

and calling the event as

event(new \App\Events\SendWaitingForRedirect('hello world'));

I don't know what's wrong. Can you please help?

I checked errors on the pusher. It is not having any errors. Can you please help.

Jatin Raikwar
  • 406
  • 5
  • 17

1 Answers1

0

You are not used the proper syntax of channel and event. The syntax is look like this

class SendWaitingForRedirect implements ShouldBroadcast
 {
use Dispatchable, InteractsWithSockets, SerializesModels;

public $message;

public function __construct($message)
{
    $this->message = $message;
}

public function broadcastOn()
{
     return new Channel('my-channel');//Use the different type of channel as you want

}

public function broadcastAs()
{
    return $this->message; //Return data as you want
}
}

Hope it helps.

salman faris
  • 125
  • 1
  • 1
  • 18