PHP code example of rongself / laravel-luosimao-sms

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

    

rongself / laravel-luosimao-sms example snippets


'providers' => [
        Rongself\Luosimao\Providers\LuosimaoSmsProvider::class
],



namespace App\Notifications;

use Illuminate\Notifications\Notification;
use Rongself\Luosimao\Channels\SmsChannel;

/**
 * Class ChargeResult
 * @package App\Notifications
 */
class ChargeResult extends Notification 
{

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [SmsChannel::class];
    }
    
    //定义短信内容
    public function toSmsMessage($notifiable)
    {
        return '验证码:19272【铁壳测试】';
    }
}




namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;

class User extends Model
{
    use Notifiable;
    
    //添加getPhone方法返回相应字段
    public function getPhone()
    {
        return $this->Tel;
    }

}



//发送通知消息
$user = User::find(1);
$message = new ChargeResult();
$user->notify($message);

bash
php artisan vendor:publish