PHP code example of bitarun / laravel-notification-service

1. Go to this page and download the library: Download bitarun/laravel-notification-service 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/ */

    

bitarun / laravel-notification-service example snippets


use Bitarun\LaravelNotificationService\Facades\Notification;

Notification::sendEmail($user->email, new \App\Mail\WelcomeMail);

use Bitarun\LaravelNotificationService\Facades\Notification;

Notification::sendSms($user->phone_number, 'کد تایید شما: ۱۲۳۴۵');

use Bitarun\LaravelNotificationService\DTOs\NotificationRecipient;
use Bitarun\LaravelNotificationService\Facades\Notification;

$recipient = new NotificationRecipient(
    email: $user->email,
    name: $user->name
);

Notification::sendEmail($recipient, new \App\Mail\WelcomeMail);

Notification::queue()->sendEmail($user->email, new \App\Mail\WelcomeMail);

Notification::now()->sendSms($user->phone_number, 'این پیام فوری ارسال می‌شود');

Notification::sendEmail($user->email, new \App\Mail\WelcomeMail);

use Bitarun\LaravelNotificationService\Exceptions\SmsSendingFailedException;

try {
    Notification::sendSms($user->phone_number, 'کد تایید: ۱۲۳۴۵');
} catch (SmsSendingFailedException $e) {
    logger()->error('ارسال پیامک ناموفق بود: ' . $e->getMessage());
}

use Bitarun\LaravelNotificationService\Facades\Notification;

Notification::sendEmail($user->email, new \App\Mail\WelcomeMail);

use Bitarun\LaravelNotificationService\Facades\Notification;

Notification::sendSms($user->phone_number, 'Your verification code: 12345');

use Bitarun\LaravelNotificationService\DTOs\NotificationRecipient;
use Bitarun\LaravelNotificationService\Facades\Notification;

$recipient = new NotificationRecipient(
    email: $user->email,
    name: $user->name
);

Notification::sendEmail($recipient, new \App\Mail\WelcomeMail);

Notification::queue()->sendEmail($user->email, new \App\Mail\WelcomeMail);

Notification::now()->sendSms($user->phone_number, 'This message is sent immediately');

Notification::sendEmail($user->email, new \App\Mail\WelcomeMail);

use Bitarun\LaravelNotificationService\Exceptions\SmsSendingFailedException;

try {
    Notification::sendSms($user->phone_number, 'Verification code: 12345');
} catch (SmsSendingFailedException $e) {
    logger()->error('SMS sending failed: ' . $e->getMessage());
}
bash
php artisan vendor:publish --tag=notification-config
bash
php artisan vendor:publish --tag=notification-config