22
33namespace NotificationChannels \Telegram ;
44
5+ use Illuminate \Support \Facades \View ;
56use JsonSerializable ;
67use NotificationChannels \Telegram \Traits \HasSharedLogic ;
8+ use Psr \Http \Message \StreamInterface ;
79
810/**
911 * Class TelegramFile.
@@ -55,9 +57,9 @@ public function content(string $content): self
5557 *
5658 * Generic method to attach files of any type based on API.
5759 *
58- * @param string $file
59- * @param string $type
60- * @param string|null $filename
60+ * @param string|resource|StreamInterface $file
61+ * @param string $type
62+ * @param string|null $filename
6163 *
6264 * @return $this
6365 */
@@ -69,7 +71,7 @@ public function file($file, string $type, string $filename = null): self
6971
7072 if ($ filename !== null || $ isLocalFile ) {
7173 $ this ->payload ['file ' ] = [
72- 'filename ' => $ filename ,
74+ 'filename ' => $ filename ,
7375 'name ' => $ type ,
7476 'contents ' => $ isLocalFile ? fopen ($ file , 'rb ' ) : $ file ,
7577 ];
@@ -182,6 +184,21 @@ public function videoNote(string $file): self
182184 return $ this ->file ($ file , 'video_note ' );
183185 }
184186
187+ /**
188+ * Attach a view file as the content for the notification.
189+ * Supports Laravel blade template.
190+ *
191+ * @param string $view
192+ * @param array $data
193+ * @param array $mergeData
194+ *
195+ * @return $this
196+ */
197+ public function view (string $ view , array $ data = [], array $ mergeData = []): self
198+ {
199+ return $ this ->content (View::make ($ view , $ data , $ mergeData )->render ());
200+ }
201+
185202 /**
186203 * Determine there is a file.
187204 *
0 commit comments