Files
portal-api/app/Http/Services/PusherNotification.php
2025-07-24 16:18:27 +07:00

39 lines
876 B
PHP

<?php
namespace App\Http\Services;
use GuzzleHttp\Exception\GuzzleException;
use Pusher\ApiErrorException;
use Pusher\Pusher;
use Pusher\PusherException;
class PusherNotification
{
//
/**
* @throws PusherException
* @throws ApiErrorException
* @throws GuzzleException
* @throws \JsonException
*/
public function Notification($message = '', $error = true): void
{
//Pusher
$pusher = new Pusher(
env('PUSHER_APP_KEY'),
env('PUSHER_APP_SECRET'),
env('PUSHER_APP_ID'),
[
'cluster' => env('PUSHER_APP_CLUSTER')
]
);
$pusher->trigger('Notification',
'Notification-Event',
json_encode([
'error' => $error,
'message' => $message
], JSON_THROW_ON_ERROR));
}
}