My goal is to send data (in this case, messages) to a group of users, and I'm specifically referring to a particular group with an ID of 1.
How are you broadcasting the event to the channel? What is on this route: "trip.event"
Route::post('/tripEvent', function (Request $request){ TripEvent::dispatch($request->trip_id,$request->message); })->name('trip.event');
$trip_id definitely has the value 1 (which I also tried to enter as a constant). Let's say I have a certain group of users that belongs to $trip = 1 and I want them to receive page changes without refreshing it. Also im using soketi for broadcast server
thank you in advance for your help with this example I'm trying to understand how it works in order to send more complicated data in the future. I would like to create an interface that does not require refreshing the page for any user to see changes on the page. I don't understand how exactly this $trip_id parameter is passed in the channel.
Have you set-up the correct broadcastOn
channel for TripEvent?.
Also, the authorization function of the channel must always return a boolean:
So it should look more like this:
Broadcast::channel('privateTrip.{tripId}', fn ($tripId) => $tripId == 1);
// Broadcast::channel('privateTrip.{tripId}', function ($tripId) { return $tripId == 1; }); // Or if you are using an older version of php
d1n0s liked this reply
OK. ITS WORKS <3 THANKS BRO NOW I KNOW HOW TO USE THAT :3
wizzymore, d1n0s liked this reply
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community