Files
UNIT3D-Community-Edition/app/Events/MessageSent.php
HDVinnie 5064235e28 (WIP) New Chat
- Powered by VueJS, Socket.io and Laravel Echo Server for broadcasting
events.
- Alpha Stage
- Not ready for use!!!
- https://trello.com/c/tzHOvz5h/16-shoutbox-20
2018-04-29 11:57:22 -04:00

70 lines
1.5 KiB
PHP

<?php
/**
* NOTICE OF LICENSE
*
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
* @author HDVinnie
*/
namespace App\Events;
use App\Chatroom;
use App\Message;
use App\User;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class MessageSent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
* User that sent the message
*
* @var User
*/
public $user;
/**
* Message details
*
* @var Message
*/
public $message;
/**
* Chatroom details
*
* @var Chatroom
*/
public $chatroom;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct(User $user, Chatroom $chatroom, Message $message)
{
$this->user = $user;
$this->message = $message;
$this->chatroom = $chatroom;
}
/**
* Get the channels the event should broadcast on.
*
* @return Channel|array
*/
public function broadcastOn()
{
return new PrivateChannel('chatroom.' . $this->chatroom->id);
}
}