Skip to content

[6.x] Add possibility to set custom displayName in Mailable and Notification#30551

Closed
nickurt wants to merge 1 commit intolaravel:6.xfrom
nickurt:feature/queued-custom-display-name-for-mailable-and-notification
Closed

[6.x] Add possibility to set custom displayName in Mailable and Notification#30551
nickurt wants to merge 1 commit intolaravel:6.xfrom
nickurt:feature/queued-custom-display-name-for-mailable-and-notification

Conversation

@nickurt
Copy link
Contributor

@nickurt nickurt commented Nov 9, 2019

Currently it's not possible to set a custom display name for queue'd Mail/Notifications, in the current situation the Mail/Notifications will always end up with the ClassName as DisplayName

// displayName: App\Mail\CustomMail

Mail::to('mail@mail.tld')->queue(
    (new \App\Mail\CustomMail())->delay(now()->addHour())
);

// displayName: App\Notifications\CustomNotification

Auth::user()->notify(
    (new \App\Notifications\CustomNotification())->delay(now()->addHour())
);

After this PullRequest it's possible to set a displayName on the Mailable and Notification

class CustomMail extends Mailable
{
    use Queueable, SerializesModels;

    //

    /**
     * Get the display name for the queued job.
     *
     * @return string
     */
    public function displayName()
    {
        return 'Custom Mail';
    }

    //
}

class CustomNotification extends Notification implements ShouldQueue
{
    use Queueable;
	
    //

    /**
     * Get the display name for the queued job.
     *
     * @return string
     */
    public function displayName()
    {
        return 'Custom Notification';
    }

    //
}

@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If possible, please consider releasing your code as a package so that the community can still take advantage of your contributions!

If you feel absolutely certain that this code corrects a bug in the framework, please "@" mention me in a follow-up comment with further explanation so that GitHub will send me a notification of your response.

@nickurt nickurt deleted the feature/queued-custom-display-name-for-mailable-and-notification branch November 11, 2019 14:24
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