<?php namespace App\Events; use App\Events\Event; use Illuminate\Queue\SerializesModels; use Illuminate\Contracts\Broadcasting\ShouldBroadcast; class Notification extends Event implements ShouldBroadcast { use SerializesModels; const STATUS_SUCCESS = 'success'; const STATUS_INFO = 'info'; const STATUS_WARNING = 'warning'; const STATUS_ERROR = 'error'; public $title; public $message; public $status; /** * Create a new event instance. * @param $title * @param string|null $message * @param string $status */ public function __construct($title, $message = null, $status = self::STATUS_SUCCESS) { $this->title = $title; $this->message = $message; $this->status = $status; } /** * Get the channels the event should be broadcast on. * * @return array */ public function broadcastOn() { return [ 'notification' ]; } public function broadcastWith() { return [ 'status' => $this->status, 'title' => $this->title, 'message' => $this->message ]; } }