*/ public function via(object $notifiable): array { $preferences = $notifiable->notificationPreference()->firstOrCreate([]); if (! $preferences->allows($this->type, 'database')) { return []; } return ['database']; } /** * Get the array representation of the notification. * * @return array */ public function toArray(object $notifiable): array { return [ 'type' => $this->type, 'title' => $this->title, 'body' => $this->body, 'url' => $this->url, ]; } }