class Attachment extends Attachment

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
string|null $as

The attached file's filename.

from  Attachment
string|null $mime

The attached file's mime type.

from  Attachment

Methods

static void
macro(string $name, callable|object $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Check if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

static Attachment
fromPath(string $path)

Create a mail attachment from a path.

static Attachment
fromUrl(string $url)

Create a mail attachment from a URL.

static Attachment
fromData(Closure $data, string|null $name = null)

Create a mail attachment from in-memory data.

static Attachment
fromUploadedFile(UploadedFile $file)

Create a mail attachment from an UploadedFile instance.

static Attachment
fromStorage(string $path)

Create a mail attachment from a file in the default storage disk.

static Attachment
fromStorageDisk(string|null $disk, string $path)

Create a mail attachment from a file in the specified storage disk.

static Filesystem
getStorageDisk(string|null $disk)

Get a storage disk instance.

as(string|null $name)

Set the attached file's filename.

withMime(string $mime)

Set the attached file's mime type.

mixed
attachWith(Closure $pathStrategy, Closure $dataStrategy)

Attach the attachment with the given strategies.

mixed
attachTo(Mailable|MailMessage|Message $mail, array $options = [])

Attach the attachment to a built-in mail type.

bool
isEquivalent(Attachment $attachment, array $options = [])

Determine if the given attachment is equivalent to this attachment.

static void
flushState()

Flush all static state.

Details

in Macroable at line 28
static void macro(string $name, callable|object $macro)

Register a custom macro.

Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.

Parameters

string $name
callable|object $macro

Return Value

void

in Macroable at line 41
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

in Macroable at line 57
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line 68
static void flushMacros()

Flush the existing macros.

Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.

Return Value

void

in Macroable at line 78
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line 103
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Attachment at line 45
static Attachment fromPath(string $path)

Create a mail attachment from a path.

Parameters

string $path

Return Value

Attachment

in Attachment at line 53
static Attachment fromUrl(string $url)

Create a mail attachment from a URL.

Parameters

string $url

Return Value

Attachment

in Attachment at line 61
static Attachment fromData(Closure $data, string|null $name = null)

Create a mail attachment from in-memory data.

Parameters

Closure $data
string|null $name

Return Value

Attachment

in Attachment at line 71
static Attachment fromUploadedFile(UploadedFile $file)

Create a mail attachment from an UploadedFile instance.

Parameters

UploadedFile $file

Return Value

Attachment

in Attachment at line 85
static Attachment fromStorage(string $path)

Create a mail attachment from a file in the default storage disk.

Parameters

string $path

Return Value

Attachment

in Attachment at line 93
static Attachment fromStorageDisk(string|null $disk, string $path)

Create a mail attachment from a file in the specified storage disk.

Parameters

string|null $disk
string $path

Return Value

Attachment

in Attachment at line 110
static protected Filesystem getStorageDisk(string|null $disk)

Get a storage disk instance.

Parameters

string|null $disk

Return Value

Filesystem

in Attachment at line 120
Attachment as(string|null $name)

Set the attached file's filename.

Parameters

string|null $name

Return Value

Attachment

in Attachment at line 130
Attachment withMime(string $mime)

Set the attached file's mime type.

Parameters

string $mime

Return Value

Attachment

in Attachment at line 140
mixed attachWith(Closure $pathStrategy, Closure $dataStrategy)

Attach the attachment with the given strategies.

Parameters

Closure $pathStrategy
Closure $dataStrategy

Return Value

mixed

in Attachment at line 150
mixed attachTo(Mailable|MailMessage|Message $mail, array $options = [])

Attach the attachment to a built-in mail type.

Parameters

Mailable|MailMessage|Message $mail
array $options

Return Value

mixed

in Attachment at line 176
bool isEquivalent(Attachment $attachment, array $options = [])

Determine if the given attachment is equivalent to this attachment.

Parameters

Attachment $attachment
array $options

Return Value

bool

in Attachment at line 193
static void flushState()

Flush all static state.

Return Value

void