Laravel notification with livewire

Hello folks, I'm stuck with laravel notification. It's not related to the filament. But I'm using filament for this project. In the laravel community, no one helps out yet btw. The things I'm trying to send notifications when a user comments on posts. In the database notifications data is there but I can't fetch the data that give me null or empty. I'm not using a queue. Hope you guys help me. I was stucking the whole day. Thank you.

$users->unreadNotifications;
= Illuminate\Notifications\DatabaseNotificationCollection {#5579
    all: [],
  }


<?php

namespace App\Notifications;

use App\Models\Comment;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;

class NotifyWhenComment extends Notification
{
    use Queueable;

    /**
     * Create a new notification instance.
     */
    public function __construct(public Comment $comment)
    {
        //
    }

    /**
     * Get the notification's delivery channels.
     *
     * @return array<int, string>
     */
    public function via(object $notifiable): array
    {
        return ['database'];
    }

    /**
     * Get the array representation of the notification.
     *
     * @return array<string, mixed>
     */
    public function toArray(object $notifiable): array
    {
        return [
            'comment_id' => $this->comment->id,
            'comment_content' => $this->comment->content,
            'user_avatar' => $this->comment->user->profile_photo_url,
            'user_name' => $this->comment->user->name,
            'feeling_id' => $this->comment->feeling->id,
            'feeling_slug' => $this->comment->feeling->slug,
            'feeling_title' => $this->comment->feeling->title,
        ];
    }
}
Was this page helpful?