Skip to content

Custom theme not used for markdown notifications #56358

@Baspa

Description

@Baspa

Laravel Version

11.44.2

PHP Version

8.1

Database Driver & Version

No response

Description

A "markdown notification" will not apply CSS from a custom theme when a CSS file is created in the themes directory and set in the notifcation. It seems to always fallback to default, even when another (existing) theme is set.

Steps To Reproduce

  • Create a new Laravel installation
  • Publish mailable views: php artisan vendor:publish --tag=laravel-mail
  • Create a new markdown notification: php artisan make:notification InvoicePaid --markdown=mail.invoice.paid
  • Create a new theme css file: views/vendor/mail/html/themes/test.css with some css that clearly deviates from the default theme
  • Change the theme inside the notification:
<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Support\HtmlString;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;

class InvoicePaidNotification extends Notification
{
    use Queueable;

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

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

    /**
     * Get the mail representation of the notification.
     */
    public function toMail(object $notifiable): MailMessage
    {
        return (new MailMessage)
            ->theme('test')
            ->subject('This is just a test')
            ->greeting('Hey ' . $notifiable->name . ',')
            ->line('Thanks for testing this!');
    }

    /**
     * Get the array representation of the notification.
     *
     * @return array<string, mixed>
     */
    public function toArray(object $notifiable): array
    {
        return [
            //
        ];
    }
}
  • Render the notification and see that the test css is NOT applied

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions