VulnerabilityCreated.php
1 <?php 2 3 namespace App\Notifications; 4 5 use App\Models\TOE; 6 use Illuminate\Bus\Queueable; 7 use Illuminate\Contracts\Queue\ShouldQueue; 8 use Illuminate\Notifications\Messages\MailMessage; 9 use Illuminate\Notifications\Notification; 10 use Illuminate\Support\Collection; 11 12 class VulnerabilityCreated extends Notification 13 { 14 use Queueable; 15 16 /** 17 * Create a new notification instance. 18 * 19 * @return void 20 */ 21 public function __construct(private Collection $vulnerabilities, private TOE $toe) 22 { 23 // 24 } 25 26 /** 27 * Get the notification's delivery channels. 28 * 29 * @param mixed $notifiable 30 * @return array 31 */ 32 public function via($notifiable) 33 { 34 return ['database']; 35 } 36 37 /** 38 * Get the array representation of the notification. 39 * 40 * @param mixed $notifiable 41 * @return array 42 */ 43 public function toArray($notifiable) 44 { 45 return [ 46 'user_id' => $notifiable->id, 47 'title' => __('notifications.message-title.VulnerabilityCreated', [ 48 'title' => $this->toe->title 49 ]), 50 'message' => __('notifications.messages.VulnerabilityCreated', [ 51 'toeName' => $this->toe->name 52 ]), 53 'toe_id' => $this->toe->id, 54 ]; 55 } 56 }