File tree Expand file tree Collapse file tree 5 files changed +90
-1
lines changed Expand file tree Collapse file tree 5 files changed +90
-1
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace DescomMarket \Common \Notifications ;
4
+
5
+ use Illuminate \Bus \Queueable ;
6
+ use Illuminate \Contracts \Queue \ShouldQueue ;
7
+ use Illuminate \Notifications \Notification ;
8
+
9
+ abstract class NotificationDescomMarket extends Notification implements ShouldQueue
10
+ {
11
+ use Queueable;
12
+
13
+ public function __construct ()
14
+ {
15
+ $ this ->onConnection (config ('dm360.notifications.queue.connection ' , 'sync ' ));
16
+
17
+ $ this ->onQueue (config ('dm360.notifications.queue.name ' ));
18
+ }
19
+ }
Original file line number Diff line number Diff line change
1
+ # Notifications
2
+
3
+ ## NotificationDescomMarket
4
+
5
+ NotificationDescomMarket you can extend to create your own queue notification.
6
+
7
+ You need define this config in ` dm360.php ` file;
8
+
9
+ ``` php
10
+ 'notification' => [
11
+ 'queue' => [
12
+ 'connection' => 'database',
13
+ 'name' => 'default',
14
+ ],
15
+ ],
16
+ ```
17
+
18
+ Then you need extends ` NotificationDescomMarket ` for your notifications
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace DescomMarket \Common \Tests \Feature \Notifications ;
4
+
5
+ use DescomMarket \Common \Notifiables \AdminNotifiable ;
6
+ use DescomMarket \Common \Tests \Stubs \TestNotification ;
7
+ use DescomMarket \Common \Tests \TestCase ;
8
+ use Illuminate \Support \Facades \Notification ;
9
+
10
+ class NotificationDescomMarketTest extends TestCase
11
+ {
12
+ public function testSendReportNotification ()
13
+ {
14
+ Notification::fake ();
15
+
16
+ AdminNotifiable::configEmails (['sample@example.com ' ]);
17
+
18
+ (new AdminNotifiable ())->notify (new TestNotification ('message ' ));
19
+
20
+ Notification::assertSentTo (
21
+ (new AdminNotifiable ()),
22
+ TestNotification::class
23
+ );
24
+ }
25
+ }
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- namespace DescomMarket \Common \Tests \Feature ;
3
+ namespace DescomMarket \Common \Tests \Feature \ Notifications ;
4
4
5
5
use DescomMarket \Common \Notifiables \AdminNotifiable ;
6
6
use DescomMarket \Common \Notifications \Admin \ReportNotification ;
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace DescomMarket \Common \Tests \Stubs ;
4
+
5
+ use DescomMarket \Common \Notifications \NotificationDescomMarket ;
6
+ use Illuminate \Notifications \Messages \MailMessage ;
7
+
8
+ class TestNotification extends NotificationDescomMarket
9
+ {
10
+ public function __construct (public readonly string $ message )
11
+ {
12
+ }
13
+
14
+ public function via ($ notifiable ): array
15
+ {
16
+ return ['mail ' ];
17
+ }
18
+
19
+ public function toMail ($ notifiable ): MailMessage
20
+ {
21
+ return (new MailMessage ())
22
+ ->subject ('Test Notification ' )
23
+ ->line ($ this ->message );
24
+ }
25
+
26
+
27
+ }
You can’t perform that action at this time.
0 commit comments