File: /home/imensosw/www/mpl.imenso.co/app/Events/FanCommentOnPost.php
<?php
namespace App\Events;
use App\Models\Comment as Comment;
use App\Models\User as User;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class FanCommentOnPost
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $comment;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct(Comment $comment)
{
$this->comment = $comment;
}
/*
* Get the channels the event should broadcast on.
*
* @return Channel|array
*/
// public function broadcastOn()
// {
// $channels = [];
// if($this->comment->post->comments()->whereIn('user_id', $this->comment->user->friends())->count() > 0){
// foreach($this->comment->post->comments()->whereIn('user_id', $this->comment->user->friends())->distinct('user_id')->get() as $friends_comment)
// {
// $channels[] = new PrivateChannel('user_'.$this->requestee->id);
// }
// }
// return $channels;
// }
// public function broadcastAs()
// {
// return 'fan.friend.also.commented.on.post';
// }
// public function broadcastWith()
// {
// return [
// 'action' => 'add-notification',
// 'html' => view('notifications/fan/friend-also-commented-on-post')->with([
// 'comment' => $this->comment
// ])->render()
// ];
// }
}