PHP code example of sierratecnologia / transmissor
1. Go to this page and download the library: Download sierratecnologia/transmissor 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/ */
sierratecnologia / transmissor example snippets
return [
// Add custom configuration here if needed
];
use Transmissor\Services\NotificationService;
$notificationService = app(NotificationService::class);
// Send a notification to a specific user
$notificationService->notify(
$userId,
'info', // flag: info, warning, error, success
'Welcome to Transmissor',
'This is a detailed notification message.'
);
// Create a notification with full control
$notificationService->create([
'user_id' => $userId,
'flag' => 'success',
'title' => 'Task Completed',
'details' => 'Your task has been completed successfully.',
]);
// Broadcast to all users (user_id = 0)
$notificationService->create([
'user_id' => 0,
'flag' => 'announcement',
'title' => 'System Maintenance',
'details' => 'Scheduled maintenance on Sunday.',
]);
// Get all notifications (paginated)
$notifications = $notificationService->paginated();
// Get notifications for a specific user
$userNotifications = $notificationService->userBased($userId);
// Get paginated notifications for a user
$userNotifications = $notificationService->userBasedPaginated($userId);
// Search notifications
$results = $notificationService->search('keyword', $userId);
// Find by UUID
$notification = $notificationService->findByUuid($uuid);
// Mark as read
$notificationService->markAsRead($notificationId);
// Update a notification
$notificationService->update($notificationId, [
'title' => 'Updated Title',
'details' => 'Updated details',
]);
// Delete a notification
$notificationService->destroy($notificationId);
use Transmissor\Facades\Notifications;
// Access notification service methods through the facade
Notifications::notify($userId, 'info', 'Title', 'Details');
use Transmissor\Models\Messenger\Thread;
use Transmissor\Models\Messenger\Message;
use Transmissor\Models\Messenger\Participant;
// Create a new thread
$thread = Thread::create([
'subject' => 'Discussion Topic',
]);
// Add the first message
$message = Message::create([
'thread_id' => $thread->id,
'user_id' => auth()->id(),
'body' => 'Hello! This is the first message.',
]);
// Add participants
$thread->addParticipant($userId);
$thread->addParticipants([$userId1, $userId2, $userId3]);
use Transmissor\Traits\Messagable;
class User extends Authenticatable
{
use Messagable;
// Your user model code...
}
// Get all threads for a user
$threads = $user->threads();
// Get unread messages count
$unreadCount = $user->unreadMessagesCount();
// Check if user is participant in a thread
$isParticipant = $user->isParticipantInThread($threadId);
// Get all threads
$threads = Thread::getAllLatest();
// Get threads for current user
$userThreads = Thread::forUser(auth()->id());
// Get messages in a thread
$messages = $thread->messages;
// Get latest message
$latestMessage = $thread->latestMessage;
// Get participants
$participants = $thread->participants;
use Transmissor\Services\ActivityService;
$activityService = app(ActivityService::class);
// Log an activity
$activityService->log('User viewed dashboard');
// Get activities for a user
$activities = $activityService->getByUser($userId);
// Get paginated activities
$activities = $activityService->getByUser($userId, 25);
// Log an activity anywhere in your application
activity('User completed checkout process');
activity('Admin updated settings');
use Transmissor\Http\Middleware\Activity;
Route::middleware([Activity::class])->group(function () {
// Your routes here
});
use Transmissor\Http\Controllers\Webhook\StoreController;
use Transmissor\Http\Controllers\WebhookReceivedController;
use Transmissor\Jobs\Webhook\UptimeCheckFailed;
use Transmissor\Jobs\Webhook\BrokenLinksFound;
namespace App\Jobs;
use Transmissor\Jobs\Webhook\UptimeCheckFailed;
class HandleUptimeAlert extends UptimeCheckFailed
{
public function handle()
{
// Your custom webhook handling logic
$payload = $this->webhookCall->payload;
// Process the webhook data
// Send notifications, update database, etc.
}
}
use Transmissor\Facades\Transmissor;
// Access the main Transmissor service
Transmissor::method();
use Transmissor\Facades\Notifications;
// Access notification service methods
Notifications::notify($userId, 'info', 'Title', 'Details');
use Transmissor\Facades\Activity;
// Access activity service methods
Activity::log('User performed action');