PHP code example of foolkaka / laravel-notification-dayu

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

    

foolkaka / laravel-notification-dayu example snippets


// config/app.php
'providers' => [
    ...
    NotificationChannels\Dayusms\DayusmsServiceProvider::class,
],

// config/services.php
...
'dayu' => [
    'app_key' => env('DAYU_APP_KEY'),
    'app_secret' => env('DAYU_APP_SECRET'),
    'format' => 'json',
    'log_dir' => '/tmp',
    'sms_from' => env('DAYU_SMS_SIGN_NAME'),
    'sms_type' => 'normal',
    'sms_template' => env('DAYU_SMS_TEMPLATE','SMS_9655108')
],
...

public function routeNotificationForDayusms()
{
    // where `phone` is a field in your users table;
    // can set multiple phones as string which separated by comma `,` .
    return $this->phone;
}
 php
use NotificationChannels\Dayusms\DayusmsChannel;
use NotificationChannels\Dayusms\DayusmsMessage;
use Illuminate\Notifications\Notification;

class ValentineDateApproved extends Notification
{
    public function via($notifiable)
    {
        return [DayusmsChannel::class];
    }

    public function toDayusms($notifiable)
    {
        return (new DayusmsMessage())
            ->content('{"level":"P0", "service":"'.$notifiable->service.'", "info":"502"}');
    }
}