Answer the question
In order to leave comments, you need to log in
Why doesn't pusher-event work in Laravel?
Set up notifications in laravel as follows:
.env:
BROADCAST_DRIVER=pusher
PUSHER_APP_ID=here is my id
PUSHER_APP_KEY=here is my app_key
PUSHER_APP_SECRET=here is my app_secret
PUSHER_APP_CLUSTER=ap2
broadcasting.php:
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'useTLS' => true,
],
],
<?php
namespace App\Events;
use App\Models\Challenge;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class Challenged implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $challenge;
public function __construct(Challenge $challenge){
$this->challenge = $challenge;
}
public function broadcastOn()
{
// return new Channel('challenge-channel');
return ['challenge-channel'];
}
public function broadcastAs()
{
return 'challenge-event';
}
}
$challenge = (new Challenge())->create($challenge_fields);
event(new Challenged($challenge));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question