Skip to content

Commit ef9a63d

Browse files
committed
Message to slack.
1 parent 1b80e20 commit ef9a63d

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ LaravelDeveloper::exceptionToDevSlack(
7373
);
7474
```
7575

76+
### Send message to slack
77+
78+
Use this to send any message to your dev slack:
79+
80+
```php
81+
use Binarcode\LaravelDeveloper\LaravelDeveloper;
82+
83+
LaravelDeveloper::messageToDevSlack('Hey, we have troubles ;-)');
84+
```
85+
7686
### Send anything to slack
7787

7888
Obviously, you can send any kind of message to the slack channel. The `toDevSlack` method accept an instance of `DevNotificationDto`:

src/LaravelDeveloper.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ public static function exceptionToDevSlack(Throwable $t)
5151
));
5252
}
5353

54+
public static function messageToDevSlack(string $message)
55+
{
56+
/**
57+
* @var string $class
58+
*/
59+
$class = config('developer.notification', DevNotification::class);
60+
61+
static::notifyDev(new $class(
62+
DevNotificationDto::makeWithMessage($message)
63+
));
64+
}
65+
5466
public static function exceptionLogToDevSlack(ExceptionLog $log)
5567
{
5668
/**

tests/Models/LaravelDeveloperTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,13 @@ public function test_can_notify_any_dto()
5252

5353
Notification::assertSentTo(new AnonymousNotifiable, DevNotification::class);
5454
}
55+
56+
public function test_can_notify_with_message()
57+
{
58+
Notification::fake();
59+
60+
LaravelDeveloper::messageToDevSlack('wew');
61+
62+
Notification::assertSentTo(new AnonymousNotifiable, DevNotification::class);
63+
}
5564
}

0 commit comments

Comments
 (0)