Create A Realtime Chatroom With Laravel, VueJS And Pusher

Submitted by azazqadir - 1 week ago

Here is a list of components that are going to be used for this application: Laravel Auth Laravel Mix Laravel Broadcast Pusher for Laravel and VueJS Bootstrap Source: https://www.cloudways.com/blog/realtime-chatroom-with-laravel-vuejs-pusher/

<?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 ChatMessage implements ShouldBroadcast

{

   use Dispatchable, InteractsWithSockets, SerializesModels;

   public $user;

   /**

    * Create a new event instance.

    *

    * @return void

    */

   public function __construct($user)

   {

       //

       $this->user = $user;

   }

   /**

    * Get the channels the event should broadcast on.

    *

    * @return Channel|array

    */

   public function broadcastOn()

   {
       return ['chat-message'.$this->user['id']];
   }

}
comments powered by Disqus

Ads cover the costs of maintaining Laravel-tricks