30 lines
693 B
PHP
Executable File
30 lines
693 B
PHP
Executable File
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
class NotificationService
|
|
{
|
|
protected $endpoint;
|
|
protected $primaryKey;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->endpoint = 'https://<your-namespace>.servicebus.windows.net/<your-notification-hub>/messages';
|
|
$this->primaryKey = env('AZURE_NOTIFICATION_HUB_PRIMARY_KEY');
|
|
}
|
|
|
|
public function sendNotification($message)
|
|
{
|
|
$response = Http::withHeaders([
|
|
'Authorization' => $this->primaryKey,
|
|
'Content-Type' => 'application/json'
|
|
])->post($this->endpoint, [
|
|
'data' => $message
|
|
]);
|
|
|
|
return $response->json();
|
|
}
|
|
}
|