PHP code example of weiwait / dcat-easy-sms

1. Go to this page and download the library: Download weiwait/dcat-easy-sms 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/ */

    

weiwait / dcat-easy-sms example snippets


    public function index(Content $content): Content
    {
        $tab = Tab::make();
        $tab->add('短信', new \Weiwait\DcatEasySms\Forms\SmsConfig());

        return $content->title('配置')
            ->body($tab->withCard());
    }

class SomeNotification extends Notification
{
    public function via()
    {
        return [\Weiwait\DcatEasySms\Channels\EasySmsChannel::class];
    }
    
    public function toEasySms($notifiable)
    {
        return [
            'to' => $notifiable,
            'template' => 'SMS_000001',
            'content' => '免模板消息内容',
            'data' => [
                'code' => '模板消息变量${code}'
            ]           
        ]
    }
}

class User extends Model
{
    use Notifiable;
    
    public function routeNotificationForEasySms($notifiable)
    {
        return $this->phone;
    }
}

class SomeNotification extends Notification
{
    public function via()
    {
        return [\Weiwait\DcatEasySms\Channels\EasySmsChannel::class];
    }
    
    public function toEasySms($notifiable)
    {
        return [
            'template' => 'SMS_000001',
            'data' => [
                'code' => '模板消息变量${code}'
            ]           
        ]
    }
}

Notification::send('15626326950', new SomeNotification());

(new User())->nofity(new SomeNotification());