Skip to content

Instantly share code, notes, and snippets.

@MrAtiebatie
Last active May 2, 2018 09:49
Show Gist options
  • Save MrAtiebatie/a6d410084904a32ab682bdc9716b2dc3 to your computer and use it in GitHub Desktop.
Save MrAtiebatie/a6d410084904a32ab682bdc9716b2dc3 to your computer and use it in GitHub Desktop.
<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class SendMessage implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
* Message
* @var string
*/
public $message;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct(string $message)
{
$this->message = $message;
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new PrivateChannel('messages');
}
/**
* The event's broadcast name.
*
* @return string
*/
public function broadcastAs()
{
return 'message.sent';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment