PHP code example of ivfuture / laravel-event-notification
1. Go to this page and download the library: Download ivfuture/laravel-event-notification library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ivfuture / laravel-event-notification example snippets
// at the top of your class
use NotificationTrait;
//Controller's constructor
public function __construct()
{
//subscribe to all the notification channels from database
$this->subscribeToNotificationChannels();
// ...
}
//sending a notification
$notification_channel = NotificationChannel::where('label', 'post-liked')->first();
if (!isset($notification_channel)) {
return response()->json(['success' => false]);
}
$this->sendNotification($p_sender_id, $p_receiver_id, $p_notifiable_type, $p_notifiable_id, $notification_channel->id, $p_title, $p_description);