PHP code example of byteblitz / notify
1. Go to this page and download the library: Download byteblitz/notify 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/ */
byteblitz / notify example snippets
'providers' => [
...
ByteBlitz\Notify\NotifyServiceProvider::class
...
];
use ByteBlitz\Notify\Facades\Notify;
$templates = [
[
'session'=>'New Registration To Admin',
'receiver'=> 'admin',
'slug' => 'new_registration_to_admin',
'title' => 'New Registration',
'mail_msg' => "<p>Hy Admin,</p><p> {name} is registered in ByteBlitz, Please review and verify. </p>",
'notification_msg'=>"",
'variables' => ['name'],
'channels'=>['mail', 'fcm']
],
[
'session'=>'Registration success to customer',
'receiver'=> 'customer',
'slug' => 'registration_success_to_customer',
'title' => 'Welcome to ByteBlitz',
'notification_msg'=>"",
'mail_msg' => "<p>Hy {name},</p><p> We'd like to welcome you to <strong>ByteBlitz</strong>, and thank you for joining us.</p>",
'variables' => ['name'],
'channels'=>['mail']
],
];
foreach($templates as $template) {
Notify::createTemplate($template);
}
//To get template
Notify::getTemplate('slug');
//To update template
Notify::updateTemplate($templateData, $id);
//To delete template
Notify::dropTemplate($id);
//To restore deleted template
Notify::restoreTemplate('slug');
use ByteBlitz\Notify\Trait\NotifyBlitz;
//variables need to be override so define template variables :
$variables = [
'name'=>'Jhon'
];
$user->template('registration_success_to_customer', $variables)->notify();
$user->template('registration_success_to_customer', $variables, true, 'redirection route or url')->notify();
$user->template('registration_success_to_customer', $variables)->->attachments(['../attachment/path'])->notify();
//mailable class
$user
->customMail(new \App\Mail\CustomMail())
//custom to mail
->toMail('[email protected] ')
//custom phone number to send sms or whatsapp notification
->toPhone('+9198776*****')
//send custom messages
->via(['mail', 'fcm', 'whatsapp', 'sms'])
->title('Hellooooo')
->mailMsg('Mail Msg')
->message('notification message')
->notify();
notifyButton('https://www.facebook.com/', 'Create Account');
notifyImage('https://picperf.io/https://laravelnews.s3.amazonaws.com/images/laravel-featured.png');
'receivers'=>[
'user'=>App\Models\User::class,
'admin'=>App\Models\Admin::class
],
'mail'=>[
'title'=>'ByteBlitz',
'logo'=>'',
'primary_clr'=>'red'
],
//For firebase
'fcm'=> [
'server_key'=>env('FCM_SERVER_KEY')
],
//For Whatsapp use ultramsg api provider
'whatsapp'=> [
'ultramsg'=>[
'instance_id'=> env('ULTRAMSG_INSTANCE_ID'),
'token'=> env('ULTRAMSG_TOKEN'),
],
'attachments_allowed'=>[
'documents'=>['pdf'],
'images'=>['png', 'jpg']
]
],
//For SMS, use twilio
'sms'=> [
'twilio'=>[
'sid'=>env('TWILIO_SID'),
'auth_token'=>env('TWILIO_AUTH_TOKEN'),
'from'=>env('TWILIO_FROM_NUMBER')
]
]
$user->notifications();
sh
$ php artisan migrate