Complete the code to define a new event class in Laravel.
php artisan make:event [1]Use php artisan make:event UserRegistered to create a new event class named UserRegistered.
Complete the event class to implement the ShouldBroadcast interface.
use Illuminate\Broadcasting\[1]; class UserRegistered implements [1] { // Event properties and methods }
Implement ShouldBroadcast to make the event broadcastable.
Fix the error in the event constructor to assign the user property.
public $user;
public function __construct([1] $user)
{
$this->user = $user;
}The constructor should type hint the User model class to receive the user instance.
Fill in the blank to define the broadcastOn method returning a private channel.
public function broadcastOn()
{
return new [1]('user.' . $this->user->id);
}The broadcastOn method returns a PrivateChannel with the channel name including the user ID.
Fill all three blanks to define the broadcastWith method returning event data.
public function broadcastWith()
{
return [
'[1]' => $this->user->id,
'[2]' => $this->user->name,
'[3]' => $this->user->email,
];
}The broadcastWith method returns an array with keys matching the data sent with the event: id, name, and email.