File tree 2 files changed +40
-0
lines changed
2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,17 @@ public static function fromPath($path)
55
55
return new static (fn ($ attachment , $ pathStrategy ) => $ pathStrategy ($ path , $ attachment ));
56
56
}
57
57
58
+ /**
59
+ * Create a mail attachment from a URL.
60
+ *
61
+ * @param string $url
62
+ * @return static
63
+ */
64
+ public static function fromUrl ($ url )
65
+ {
66
+ return static ::fromPath ($ url );
67
+ }
68
+
58
69
/**
59
70
* Create a mail attachment from in-memory data.
60
71
*
Original file line number Diff line number Diff line change @@ -109,4 +109,33 @@ public function toMailAttachment()
109
109
99 ,
110
110
], $ notification ->dataArgs );
111
111
}
112
+
113
+ public function testFromUrlMethod ()
114
+ {
115
+ $ mailable = new class extends Mailable
116
+ {
117
+ public function build ()
118
+ {
119
+ $ this ->attach (new class implements Attachable
120
+ {
121
+ public function toMailAttachment ()
122
+ {
123
+ return Attachment::fromUrl ('https://example.com/file.pdf ' )
124
+ ->as ('example.pdf ' )
125
+ ->withMime ('application/pdf ' );
126
+ }
127
+ });
128
+ }
129
+ };
130
+
131
+ $ mailable ->build ();
132
+
133
+ $ this ->assertSame ([
134
+ 'file ' => 'https://example.com/file.pdf ' ,
135
+ 'options ' => [
136
+ 'as ' => 'example.pdf ' ,
137
+ 'mime ' => 'application/pdf ' ,
138
+ ],
139
+ ], $ mailable ->attachments [0 ]);
140
+ }
112
141
}
You can’t perform that action at this time.
0 commit comments