5
5
namespace App \Notifications ;
6
6
7
7
use Illuminate \Bus \Queueable ;
8
- use Illuminate \Notifications \Notification ;
9
8
use Illuminate \Database \Eloquent \Collection ;
9
+ use Illuminate \Notifications \Notification ;
10
10
use NotificationChannels \Telegram \TelegramChannel ;
11
11
use NotificationChannels \Telegram \TelegramMessage ;
12
12
13
13
final class PendingArticlesNotification extends Notification
14
14
{
15
15
use Queueable;
16
16
17
- public function __construct (public Collection $ pendingArticles )
18
- {
19
- }
17
+ public function __construct (public Collection $ pendingArticles ) {}
20
18
21
19
public function via (mixed $ notifiable ): array
22
20
{
@@ -28,24 +26,28 @@ public function toTelegram(): TelegramMessage
28
26
$ message = $ this ->content ();
29
27
30
28
return TelegramMessage::create ()
31
- ->to (config ('services.telegram-bot-api.channel ' ))->content ($ message );
29
+ ->to (config ('services.telegram-bot-api.channel ' ))
30
+ ->content ($ message );
32
31
}
33
32
34
33
private function content (): string
35
34
{
36
- $ message = __ ("Articles soumis en attente d'approbation: \n\n" );
35
+ $ heading = "*Articles soumis en attente d'approbation!* " ;
36
+ $ messages = "{$ heading }\n\n" ;
37
+
37
38
foreach ($ this ->pendingArticles as $ article ) {
38
- $ message .= __ (
39
+ $ messages .= __ (
39
40
"[@:username](:profile_url) a soumit l'article [:title](:url) le: :date \n\n" ,
40
41
[
41
42
'username ' => $ article ->user ?->username,
42
43
'profile_url ' => route ('profile ' , $ article ->user ?->username),
43
44
'title ' => $ article ->title ,
44
45
'url ' => route ('articles.show ' , $ article ->slug ),
45
- 'date ' => $ article ->submitted_at ->translatedFormat ('d M Y ' )
46
+ 'date ' => $ article ->submitted_at ->translatedFormat ('d M Y ' ),
46
47
]
47
48
);
48
49
}
49
- return $ message ;
50
+
51
+ return $ messages ;
50
52
}
51
53
}
0 commit comments