File: /home/imensosw/www/mpl.imenso.co/app/Listeners/SendArtistPromoterConnectionNotification.php
<?php
namespace App\Listeners;
use App\Events\PromoterConnectsToAnArtist;
use App\Models\Notification;
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\Facades\View;
class SendArtistPromoterConnectionNotification
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param ArtistRecommendsArtist $event
* @return void
*/
public function handle(PromoterConnectsToAnArtist $event)
{
$html = view('notifications/artists/promoter-connected')->with([
'promoter' => $event->promoter,
])->render();
$notification = $event->artist->addNotification(
102,
$html,
[
'promoter' => $event->promoter->id,
'artist' => $event->artist->id,
]
);
if ($notification) {
$html = '<a href="javascript: void(0)" onclick="clearNotification('.$notification->id.')" class="clear-btn"><i class="fa fa-close"></i></a>';
$html .= Notification::parseNotification(
view('notifications/artists/promoter-connected')->with([
'promoter' => $event->promoter,
])->render()
);
$html .= '<div class="time-ago">'.$notification->created_at->diffForHumans().'</div>';
if ($notification->getActions()) {
$html .= '<div class="action-row">'.$notification->getActions().'</div>';
}
$data = [
'action' => 'add-notification',
'html' => $html,
'id' => $notification->id,
];
Broadcast::broadcast(
[
'private-user_'.$event->artist->id,
],
'notification',
$data
);
}
}
}