© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
18 replies
Shaung Bhone

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
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: [],
  }
$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,
        ];
    }
}
<?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,
        ];
    }
}
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

laravel breeze with livewire
FilamentFFilament / ❓┊help
16mo ago
Integrating with Livewire/Laravel eventing.
FilamentFFilament / ❓┊help
3y ago
Laravel Notification Problem
FilamentFFilament / ❓┊help
6mo ago