Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.7] Added ability to set notifcation tries and timeout #26493

Merged
merged 1 commit into from
Nov 13, 2018

Conversation

therealartz
Copy link
Contributor

Allows to set $tries and $timeout properties in \Illuminate\Notifications\Notification instance.

Resolves #26175

Usage example:

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

class TestNotification extends Notification implements ShouldQueue
{
    use Queueable;

    public $tries = 3; // Max tries

    public $timeout = 15; // Timeout seconds

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

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['mail'];
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {
        return (new MailMessage)
                    ->line('The introduction to the notification.')
                    ->action('Notification Action', url('/'))
                    ->line('Thank you for using our application!');
    }
}

@taylorotwell taylorotwell merged commit 559d4ed into laravel:5.7 Nov 13, 2018
@andreshg112
Copy link

Does the notification needs to implements ShouldQueue in order to use $tries and $timeout?

@therealartz
Copy link
Contributor Author

@andreshg112 yes, when you using queue. It won't work with "sync" connection because in case of some error application will throw exception.

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.

None yet

3 participants