DocumentForApproval.php
1 <?php 2 3 namespace App\Notifications; 4 5 use App\Models\Document; 6 use Illuminate\Bus\Queueable; 7 use Illuminate\Notifications\Notification; 8 9 class DocumentForApproval extends Notification 10 { 11 use Queueable; 12 13 /** 14 * Create a new notification instance. 15 * 16 * @return void 17 */ 18 public function __construct(public Document $document) 19 { 20 // 21 } 22 23 /** 24 * Get the notification's delivery channels. 25 * 26 * @param mixed $notifiable 27 * @return array 28 */ 29 public function via($notifiable) 30 { 31 return ['database']; 32 } 33 34 /** 35 * Get the array representation of the notification. 36 * 37 * @param mixed $notifiable 38 * @return array 39 */ 40 public function toArray($notifiable) 41 { 42 return [ 43 'user_id' => $notifiable->id, 44 'title' => $this->document->name, 45 'message' => __('documents.approval.needed'), 46 ]; 47 } 48 }