Wednesday, April 12, 2017

Event broadcast is not working for laravel and angularjs

I am working in laravel5.4 and angularjs1.6. I have created frontend independent application.Like angular and html on the another domain like www.example.com and backend as laravel on the another domain like www.api-example.com.

Now, I want to implement pusher in this application. So I have send data using http request to the laravel end using api.php.

In laravel controller function, I am inserting data and after that I have created event for broadcasting. For example :

Ticket controller :

if($ticket->save())
{
    event(new \App\Events\NewTicketNotification($ticket));
}

New ticket event(NewTicketNotification) :

public function __construct(Ticket $ticket)
{
    $this->ticket = $ticket;
}
public function broadcastOn()
{
    return new PrivateChannel('ticket.'.$this->ticket->id);
}

In env file I have set environment variable for pusher. And uncomment code for pusher in bootstrap.js.

When I check debug console in pusher.com site than I could not find any connection. And this code is not working so what step should I have to follow to use pusher?



via Nisarg Bhavsar

Advertisement