Skip to content

Commit

Permalink
Add helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio Rocha committed Apr 30, 2021
1 parent 76c64d1 commit a08774c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
"autoload": {
"psr-4": {
"Frf\\DiscordNotification\\": "src/"
}
},
"files": [
"src/helpers.php"
]
},
"extra": {
"laravel": {
Expand Down
23 changes: 23 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

if (! function_exists('NotificationHelper')) {
/**
* @param string $message
*
* @return void
*/
function sendMessage(string $message): void
{
try {
$client = new \GuzzleHttp\Client();
$client->request('POST', env('DISCORD_HOOK'), [
'headers' => [
'Content-type' => 'application/json',
],
'content' => $message,
]);
} catch (\Exception $exception) {
dump($exception->getMessage());
}
}
}

0 comments on commit a08774c

Please sign in to comment.