Package Data | |
---|---|
Maintainer Username: | rongself |
Maintainer Contact: | rongself@qq.com (rongself) |
Package Create Date: | 2017-05-31 |
Package Last Update: | 2017-08-18 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-02-05 03:05:43 |
Package Statistics | |
---|---|
Total Downloads: | 97 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 0 |
螺丝帽 短信 Channel for laravel 5.4.*
composer require 'rongself/laravel-luosimao-sms'
config/app.php
注册provider:'providers' => [
Rongself\Luosimao\Providers\LuosimaoSmsProvider::class
],
php artisan vendor:publish
编辑config/luosimao-sms.php
填入app_key
<?php
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【铁壳测试】';
}
}
<?php
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;
}
}
<?php
//发送通知消息
$user = User::find(1);
$message = new ChargeResult();
$user->notify($message);
关于通知消息使用详情参考 laravel官方文档