Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

imane's avatar

imane started a new conversation+100 XP

5mos ago

this is my docker , reverb: build: context: . args: ENV: local container_name: reverb volumes: - .:/var/www env_file: - .env ports: # Expose Reverb port to your host machine for browser access (WebSockets) - "8080:8080" # Command to only start the Reverb server command: ["php", "artisan", "reverb:start", "--host=0.0.0.0"] depends_on: - db restart: unless-stopped

BROADCAST_CONNECTION=reverb QUEUE_CONNECTION=database

QUEUE_CONNECTION=sync

QUEUE_RETRY_AFTER=90 DB_QUEUE=default DB_QUEUE_TABLE=jobs DB_QUEUE_RETRY_AFTER=90

BROADCAST_DRIVER=reverb REVERB_APP_ID=**** REVERB_APP_KEY=******** REVERB_APP_SECRET=******* REVERB_HOST=reverb REVERB_PORT=8080 REVERB_SCHEME=http

this is notification <?php

namespace App\Notifications;

use App\Models\LeaveRequest; use App\Models\User; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow; use Illuminate\Notifications\Notification; use Illuminate\Notifications\Messages\BroadcastMessage;

class NewLeaveRequestNotification extends Notification implements ShouldBroadcastNow { /** * Create a new notification instance. */ public function __construct(public LeaveRequest $leaveRequest, public User $notifiableUser) { // }

/**
 * Get the notification's delivery channels.
 *
 * @return array<int, string>
 */
public function via($notifiable)
{
    return ['database', 'broadcast']; // store + real-time
}

/**
 * Centralized payload
 */
public function toArray($notifiable): array
{
    $senderName = "{$this->leaveRequest->creator->employee->last_name} {$this->leaveRequest->creator->employee->first_name}" ?? 'Système';
    $employeeName = "{$this->leaveRequest->employe->last_name} {$this->leaveRequest->employe->first_name}" ?? 'Employé inconnu';

    return [
        'message' => "Demande de congé a été soumise par {$senderName}.",
        'leave_request_id' => $this->leaveRequest->id,
        'status'           => $this->leaveRequest->status,
        'employee_name'    => $employeeName,
        'created_at'       => now()->diffForHumans(),
        // 'id'               => $this->id,
        'read_at'          => null,
        'redirect_url'     => '/leaveRequests-approvals',
    ];
}

/**
 * Get the mail representation of the notification.
 */
public function toDatabase($notifiable)
{
    return $this->toArray($notifiable);
}

public function toBroadcast($notifiable)
{
    return new BroadcastMessage($this->toArray($notifiable));
}

public function broadcastOn(): array
{
    //  dd("The user ID is:", $this->notifiableUser->id);
    return [
         new PrivateChannel("App.Models.User.{$this->notifiableUser->id}")
    ];
}

public function broadcastWith(): array
{
    return array_merge($this->toArray(null), [
        'id' => $this->id,
        'created_at' => now()->diffForHumans(),
    ]);
}

} and this is inside my store function $admins = User::role('super-admin')->get();

    foreach ($admins as $admin) {
        $admin->notify((new NewLeaveRequestNotification($leaveRequest, $admin)));
    } 

i m using spatie multitenancy i already have 'queues_are_tenant_aware_by_default' => true, i have users table , jobs , notifications inside tenant db ,, so also when i make QUEUE_CONNECTION=tenant don t work