diff --git a/README.md b/README.md index 884233d..3ba62a0 100644 --- a/README.md +++ b/README.md @@ -470,7 +470,8 @@ SmsManager::storeRule('mobile', [ ]); ``` -> 存储的动态验证规则可通过访问`host/laravel-sms/info`查看。动态验证规则的名称最好不要和静态验证规则同名,因为静态验证规则的优先级更高。 +> 存储的动态验证规则可通过访问`http[s]://your-domain/laravel-sms/info`查看。 +> 动态验证规则的名称最好不要和静态验证规则同名,因为静态验证规则的优先级更高。 #### retrieveRule($field[, $name]) @@ -504,7 +505,7 @@ SmsManager::forgetRules('mobile'); #### input([$key][, $default]) -获取客户端传递来的数据。客户端数据会自动注入到配置文件(`laravel-sms.php`)中闭包函数的第三个参数中。 +获取客户端传递来的数据。客户端数据会自动注入到配置文件(`laravel-sms.php`)中闭包函数的`$input`参数中。 ```php $mobileRuleName = SmsManager::input('mobile_rule'); $all = SmsManager::input(); diff --git a/src/Toplan/LaravelSms/SmsManager.php b/src/Toplan/LaravelSms/SmsManager.php index beae846..f58a522 100644 --- a/src/Toplan/LaravelSms/SmsManager.php +++ b/src/Toplan/LaravelSms/SmsManager.php @@ -8,7 +8,7 @@ class SmsManager { - const VERSION = '2.6.4'; + const VERSION = '2.6.5'; const STATE_KEY = '_state'; diff --git a/src/Toplan/LaravelSms/SmsManagerServiceProvider.php b/src/Toplan/LaravelSms/SmsManagerServiceProvider.php index 3c0cca6..e342657 100644 --- a/src/Toplan/LaravelSms/SmsManagerServiceProvider.php +++ b/src/Toplan/LaravelSms/SmsManagerServiceProvider.php @@ -69,25 +69,29 @@ protected function phpSms() return true; } $data = $task->data ?: []; + $to = is_array($data['to']) ? json_encode($data['to']) : $data['to']; $id = DB::table('laravel_sms')->insertGetId([ - 'to' => $data['to'] ?: '', + 'to' => $to ?: '', 'temp_id' => json_encode($data['templates']), 'data' => json_encode($data['data']), 'content' => $data['content'] ?: '', 'voice_code' => $data['code'] ?: '', 'created_at' => date('Y-m-d H:i:s', time()), ]); - $data['smsId'] = $id; + $data['_sms_id'] = $id; $task->data($data); }); PhpSms::afterSend(function ($task, $result) { - if (!config('laravel-sms.dbLogs', false) || !isset($data['smsId'])) { + if (!config('laravel-sms.dbLogs', false)) { return true; } $microTime = $result['time']['finished_at']; $finishedAt = explode(' ', $microTime)[1]; $data = $task->data; + if (!isset($data['_sms_id'])) { + return true; + } DB::beginTransaction(); $dbData = []; @@ -96,10 +100,10 @@ protected function phpSms() if ($result['success']) { $dbData['sent_time'] = $finishedAt; } else { - DB::table('laravel_sms')->where('id', $data['smsId'])->increment('fail_times'); + DB::table('laravel_sms')->where('id', $data['_sms_id'])->increment('fail_times'); $dbData['last_fail_time'] = $finishedAt; } - DB::table('laravel_sms')->where('id', $data['smsId'])->update($dbData); + DB::table('laravel_sms')->where('id', $data['_sms_id'])->update($dbData); DB::commit(); }); }