PHP code example of mucts / laravel-sms

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

    

mucts / laravel-sms example snippets



namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use MuCTS\Laravel\SMS\Channels\Channel as SMSChannel;
use MuCTS\Laravel\SMS\Interfaces\Notification as SMSNotification;
use MuCTS\SMS\Interfaces\Message as MessageInterface;
use MuCTS\Laravel\SMS\Messages\Message;
class VerificationCode extends Notification implements SMSNotification
{
    use Queueable;

    public function via($notifiable)
    {
        return [SMSChannel::class];
    }

    public function toSMS($notifiable):MessageInterface
    {
        return (new Message())
            ->setContent('您的验证码为: 6379')
            ->setTemplate('SMS_001')
            ->setData(['code' => 6379]);
    }


namespace App\Models;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use MuCTS\SMS\Mobile;

class User extends Authenticatable
{
    use Notifiable;
 
    public function routeNotificationForSMS($notification)
    {
        return new Mobile($this->mobile, $this->area_code);
    }