Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/mail/src/Contracts/Mailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ public function locale(string $locale): static;
/**
* Set the name of the mailer that should be used to send the message.
*/
public function mailer(string $mailer): static;
public function mailer(?string $mailer): static;
}
4 changes: 2 additions & 2 deletions src/mail/src/Mailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class Mailable implements MailableContract, Renderable
/**
* The name of the mailer that should send the message.
*/
public string $mailer = '';
public ?string $mailer = null;

/**
* The rendered mailable views for testing / assertions.
Expand Down Expand Up @@ -1470,7 +1470,7 @@ private function ensureAttachmentsAreHydrated(): void
/**
* Set the name of the mailer that should send the message.
*/
public function mailer(string $mailer): static
public function mailer(?string $mailer): static
{
$this->mailer = $mailer;

Expand Down
25 changes: 25 additions & 0 deletions src/mail/src/PendingMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Hypervel\Mail;

use DateInterval;
use DateTimeInterface;
use Hyperf\Conditionable\Conditionable;
use Hypervel\Mail\Contracts\Mailable as MailableContract;
use Hypervel\Mail\Contracts\Mailer as MailerContract;
Expand Down Expand Up @@ -102,6 +104,29 @@ public function sendNow(MailableContract $mailable): ?SentMessage
return $this->mailer->sendNow($this->fill($mailable));
}

/**
* Push the given mailable onto the queue.
*/
public function queue(MailableContract $mailable): mixed
{
/* @phpstan-ignore-next-line */
return $this->mailer->queue(
$this->fill($mailable)
);
}

/**
* Deliver the queued message after (n) seconds.
*/
public function later(DateInterval|DateTimeInterface|int $delay, MailableContract $mailable): mixed
{
/* @phpstan-ignore-next-line */
return $this->mailer->later(
$delay,
$this->fill($mailable)
);
}

/**
* Populate the mailable with the addresses.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/support/src/Testing/Fakes/MailFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ public function later(DateInterval|DateTimeInterface|int $delay, array|Mailable|
/**
* Infer mailable class using reflection if a typehinted closure is passed to assertion.
*/
protected function prepareMailableAndCallback(Closure|string $mailable, ?callable $callback): array
protected function prepareMailableAndCallback(Closure|string $mailable, callable|string|null $callback): array
{
if ($mailable instanceof Closure) {
return [$this->firstClosureParameterType($mailable), $mailable];
Expand Down