diff --git a/app/Notifications/GateInNotification.php b/app/Notifications/GateInNotification.php index 41c396dd..86d7f601 100644 --- a/app/Notifications/GateInNotification.php +++ b/app/Notifications/GateInNotification.php @@ -2,10 +2,10 @@ namespace App\Notifications; -use App\Models\GateIn; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Notifications\Messages\BroadcastMessage; class GateInNotification extends Notification implements ShouldQueue { @@ -31,7 +31,7 @@ public function __construct($message) */ public function via($notifiable) { - return ['database']; + return ['database', 'broadcast']; } /** @@ -46,4 +46,15 @@ public function toArray($notifiable) 'message' => $this->message ]; } + + /** + * Get the broadcastable representation of the notification. + * + * @param mixed $notifiable + * @return BroadcastMessage + */ + public function toBroadcast($notifiable) + { + return new BroadcastMessage(['message' => $this->message]); + } } diff --git a/app/Notifications/KameraErrorNotification.php b/app/Notifications/KameraErrorNotification.php index f3d2b04d..10c649d3 100644 --- a/app/Notifications/KameraErrorNotification.php +++ b/app/Notifications/KameraErrorNotification.php @@ -6,6 +6,7 @@ use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Notifications\Messages\BroadcastMessage; class KameraErrorNotification extends Notification implements ShouldQueue { @@ -13,6 +14,8 @@ class KameraErrorNotification extends Notification implements ShouldQueue public $kamera; + public $message; + /** * Create a new notification instance. * @@ -21,6 +24,7 @@ class KameraErrorNotification extends Notification implements ShouldQueue public function __construct(Kamera $kamera) { $this->kamera = $kamera; + $this->message = "Kamera {$this->kamera->nama} gagal mengambil snapshot"; } /** @@ -31,7 +35,7 @@ public function __construct(Kamera $kamera) */ public function via($notifiable) { - return ['database']; + return ['database', 'broadcast']; } /** @@ -42,8 +46,17 @@ public function via($notifiable) */ public function toArray($notifiable) { - return [ - 'message' => "Kamera {$this->kamera->nama} gagal mengambil snapshot" - ]; + return ['message' => $this->message]; + } + + /** + * Get the broadcastable representation of the notification. + * + * @param mixed $notifiable + * @return BroadcastMessage + */ + public function toBroadcast($notifiable) + { + return new BroadcastMessage(['message' => $this->message]); } } diff --git a/app/Notifications/PrintStrukFailedNotification.php b/app/Notifications/PrintStrukFailedNotification.php index bc131392..14e46222 100644 --- a/app/Notifications/PrintStrukFailedNotification.php +++ b/app/Notifications/PrintStrukFailedNotification.php @@ -6,6 +6,7 @@ use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Notifications\Messages\BroadcastMessage; class PrintStrukFailedNotification extends Notification implements ShouldQueue { @@ -13,7 +14,7 @@ class PrintStrukFailedNotification extends Notification implements ShouldQueue public $parkingTransaction; - public $error; + public $message; /** * Create a new notification instance. @@ -23,8 +24,7 @@ class PrintStrukFailedNotification extends Notification implements ShouldQueue public function __construct(ParkingTransaction $parkingTransaction, $error) { $this->parkingTransaction = $parkingTransaction; - - $this->error = $error; + $this->message = "Gagal print tiket di {$this->parkingTransaction->gateIn->nama}. {$error}"; } /** @@ -35,7 +35,7 @@ public function __construct(ParkingTransaction $parkingTransaction, $error) */ public function via($notifiable) { - return ['database']; + return ['database', 'broadcast']; } /** @@ -46,8 +46,17 @@ public function via($notifiable) */ public function toArray($notifiable) { - return [ - 'message' => "Gagal print tiket di {$this->parkingTransaction->gateIn->nama}. {$this->error}", - ]; + return ['message' => $this->message]; + } + + /** + * Get the broadcastable representation of the notification. + * + * @param mixed $notifiable + * @return BroadcastMessage + */ + public function toBroadcast($notifiable) + { + return new BroadcastMessage(['message' => $this->message]); } } diff --git a/app/Notifications/PrintTicketFailedNotification.php b/app/Notifications/PrintTicketFailedNotification.php index ec13d4fc..ab868e3f 100644 --- a/app/Notifications/PrintTicketFailedNotification.php +++ b/app/Notifications/PrintTicketFailedNotification.php @@ -6,6 +6,7 @@ use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Notifications\Messages\BroadcastMessage; class PrintTicketFailedNotification extends Notification implements ShouldQueue { @@ -13,7 +14,7 @@ class PrintTicketFailedNotification extends Notification implements ShouldQueue public $parkingTransaction; - public $error; + public $message; /** * Create a new notification instance. @@ -24,7 +25,7 @@ public function __construct(ParkingTransaction $parkingTransaction, $error) { $this->parkingTransaction = $parkingTransaction; - $this->error = $error; + $this->message = "Pengunjung di {$this->parkingTransaction->gateIn->nama} gagal print tiket. Informasikan nomor barcode kepada pengunjung. {$this->parkingTransaction->nomor_barcode}. {$error}"; } /** @@ -35,7 +36,7 @@ public function __construct(ParkingTransaction $parkingTransaction, $error) */ public function via($notifiable) { - return ['database']; + return ['database', 'broadcast']; } /** @@ -46,8 +47,17 @@ public function via($notifiable) */ public function toArray($notifiable) { - return [ - 'message' => "Pengunjung di {$this->parkingTransaction->gateIn->nama} gagal print tiket. Informasikan nomor barcode kepada pengunjung. {$this->parkingTransaction->nomor_barcode}. {$this->error}", - ]; + return ['message' => $this->message]; + } + + /** + * Get the broadcastable representation of the notification. + * + * @param mixed $notifiable + * @return BroadcastMessage + */ + public function toBroadcast($notifiable) + { + return new BroadcastMessage(['message' => $this->message]); } }