[5.4] Mailables that defined a delay property will honor it#20717
Conversation
|
If we do this I think we'll have to allow defining delay in jobs and notifications as well, but imo delaying a queued task is a decision to be taken while dispatching since a single task could be delayed in part of the code base and dispatched instantly in another. |
|
@themsaid this is already happening when you dispatch jobs afaik: https://github.com/laravel/framework/blob/5.4/src/Illuminate/Bus/Dispatcher.php#L172-L174 and I would expect a class implementing ShouldQueue to behave as the Job did, that's actually what I expected :) This is kinda related to #18144 #18160 where |
|
Yes but it wasn't meant to be used from inside the class, was never documented, it's set when you call I don't see a problem merging this PR, just wanted to share my opinion :). @taylorotwell will review it and see if he wants to merge |
This commit allows Mailables implementing
ShouldQueueto define the$delayproperty in the Mailable class. This will allow to runMail::queue(new ExampleMailable));and honor the delay.I know you can just use the
Mail::later()that will respect the defined value (or assigned with$mailable->delay($delay)) but if we're already implementing theShouldQueuecontract and even the generated Mailable class with the command makes use of theQueueableI don't see a reason why you should be forced to uselater().This also allows to add a delay to any mailable class without having to specifically find where exactly we're sending the email.