55namespace App \Notifications ;
66
77use Illuminate \Bus \Queueable ;
8- use Illuminate \Notifications \Notification ;
98use Illuminate \Database \Eloquent \Collection ;
9+ use Illuminate \Notifications \Notification ;
1010use NotificationChannels \Telegram \TelegramChannel ;
1111use NotificationChannels \Telegram \TelegramMessage ;
1212
1313final class PendingArticlesNotification extends Notification
1414{
1515 use Queueable;
1616
17- public function __construct (public Collection $ pendingArticles )
18- {
19- }
17+ public function __construct (public Collection $ pendingArticles ) {}
2018
2119 public function via (mixed $ notifiable ): array
2220 {
@@ -28,24 +26,28 @@ public function toTelegram(): TelegramMessage
2826 $ message = $ this ->content ();
2927
3028 return TelegramMessage::create ()
31- ->to (config ('services.telegram-bot-api.channel ' ))->content ($ message );
29+ ->to (config ('services.telegram-bot-api.channel ' ))
30+ ->content ($ message );
3231 }
3332
3433 private function content (): string
3534 {
36- $ message = __ ("Articles soumis en attente d'approbation: \n\n" );
35+ $ heading = "*Articles soumis en attente d'approbation!* " ;
36+ $ messages = "{$ heading }\n\n" ;
37+
3738 foreach ($ this ->pendingArticles as $ article ) {
38- $ message .= __ (
39+ $ messages .= __ (
3940 "[@:username](:profile_url) a soumit l'article [:title](:url) le: :date \n\n" ,
4041 [
4142 'username ' => $ article ->user ?->username,
4243 'profile_url ' => route ('profile ' , $ article ->user ?->username),
4344 'title ' => $ article ->title ,
4445 'url ' => route ('articles.show ' , $ article ->slug ),
45- 'date ' => $ article ->submitted_at ->translatedFormat ('d M Y ' )
46+ 'date ' => $ article ->submitted_at ->translatedFormat ('d M Y ' ),
4647 ]
4748 );
4849 }
49- return $ message ;
50+
51+ return $ messages ;
5052 }
5153}
0 commit comments