Skip to content

Conversation

amirhshokri
Copy link
Contributor

@amirhshokri amirhshokri commented Jun 10, 2025

This PR proposes a refactor in how notification classes are scaffolded using the make:notification Artisan command.

Currently, the default notification stubs (notification.stub and markdown-notification.stub) include the Illuminate\Bus\Queueable trait by default.
However, the Illuminate\Bus\Queueable trait is only actually needed if the notification implements ShouldQueue interface, because otherwise Laravel sends notifications immediately using the sendNow method, which doesn’t use the queue-related properties like connection or queue from the Illuminate\Bus\Queueable trait.

Here's a reference in https://github.com/laravel/framework/blob/12.x/src/Illuminate/Notifications/NotificationSender.php:

    /**
     * Send the given notification to the given notifiable entities.
     *
     * @param  \Illuminate\Support\Collection|array|mixed  $notifiables
     * @param  mixed  $notification
     * @return void
     */
    public function send($notifiables, $notification)
    {
        $notifiables = $this->formatNotifiables($notifiables);

        if ($notification instanceof ShouldQueue) {
            return $this->queueNotification($notifiables, $notification);
        }

        $this->sendNow($notifiables, $notification);
    }

What This PR Changes:

  • Removes the queueable trait and ShouldQueue interface from the default stubs
  • Introduces two new stubs with the queueable trait and ShouldQueue interface
  • Updates the make:notification Artisan command to use --queued flag

@taylorotwell
Copy link
Member

I personally think current setup is pretty much fine.

@amirhshokri amirhshokri deleted the add-queued-option-to-notification-make-command branch June 11, 2025 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants