'Why notification event is not triggered in pusher?

When in Laravel 9 app logged user fill ContactUs form I need to send email to site support and show notification in app for any logged support member. I make it with notification and pusher In app/Notifications/ContactUsCreatedNotification.php :

<?php

namespace App\Notifications;

use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use App\Models\User;

class ContactUsCreatedNotification extends Notification
{

    public $title;
    public $content_message;
    public $authorUser;

    public function __construct(string $title, string $content_message, User $authorUser)
    {
        $this->title           = $title;
        $this->content_message = $content_message;
        $this->authorUser      = $authorUser;
    }

    public function via($notifiable)
    {
        return ['mail', 'broadcast']; // I added broadcast here
    }

    public function toMail($notifiable)
    {
        return (new MailMessage)->markdown('mail.ContactUsCreatedNotification', [
            'title'           => $this->title,
            'content_message' => $this->content_message,
            'authorUser'      => $this->authorUser
        ]);
    }

    public function toArray($notifiable)
    {
        return [
            'title'           => $this->title,
            'content_message' => $this->content_message,
            'authorUser'      => $this->authorUser,
        ];
    }
}

I got email on configured mailtrap but Debug console of my pusher app has no event : https://prnt.sc/L9nXEfup_3i-

in .env :

BROADCAST_DRIVER=pusher
CACHE_DRIVER=file
FILESYSTEM_DISK=local
SESSION_DRIVER=database
SESSION_LIFETIME=120

PUSHER_APP_ID=NNNN
PUSHER_APP_KEY=XXXXX
PUSHER_APP_SECRET=XXXXX

PUSHER_APP_CLUSTER=eu

In resources/js/bootstrap.js :

import Echo from 'laravel-echo';

window.Pusher = require('pusher-js');

// alert('resources/js/bootstrap.js')
console.log('process.env.MIX_PUSHER_APP_KEY::')
console.log(process.env.MIX_PUSHER_APP_KEY)

console.log('process.env.MIX_PUSHER_APP_CLUSTER::')
console.log(process.env.MIX_PUSHER_APP_CLUSTER)


window.Echo = new Echo({
    broadcaster: 'pusher',
    key: process.env.MIX_PUSHER_APP_KEY,
    cluster: process.env.MIX_PUSHER_APP_CLUSTER,
    forceTLS: true
});

In the app I have

"laravel/framework": "^v9.6.0",
"predis/predis": "^1.1",
"pusher/pusher-php-server": "^7.0",

and

"laravel-echo": "^1.11.7",

Any ideas why notification event is not triggered ?

UPDATED BLOCK # 1: in .env file I set parameters

QUEUE_CONNECTION=redis

I do :

    foreach ($supportManagers as $nextSupportManager) {
        if ($nextSupportManager->user) {
            $ret = Notification::sendNow($nextSupportManager->user, new ContactUsCreatedNotification(
                $request->title,
                $request->content_message,
                auth()->user()
            ));
        }
    }

Also I tried to add Queueable definition i app/Notifications/ContactUsCreatedNotification.php file:

<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use App\Models\User;

class ContactUsCreatedNotification extends Notification  implements ShouldQueue
{
    use Queueable;

    public $title;
    public $content_message;
    public $authorUser;

But I still get email in mailtrap and not events in pusher...

Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source