Skip to content

Commit

Permalink
implements pr #149; update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
toplan committed Jun 16, 2017
1 parent a697a30 commit ef45fe2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Laravel Sms

[![StyleCI](https://styleci.io/repos/36713142/shield)](https://styleci.io/repos/36713142)
[![Latest Stable Version](https://img.shields.io/packagist/v/toplan/laravel-sms.svg)](https://packagist.org/packages/toplan/laravel-sms)
[![Total Downloads](https://img.shields.io/packagist/dt/toplan/laravel-sms.svg)](https://packagist.org/packages/toplan/laravel-sms)

一个基于`Laravel`框架的功能强大的手机号合法性验证解决方案。

### 1. 关于2.0
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"require": {
"php": ">=5.4.0",
"toplan/phpsms": "~1.7"
"toplan/phpsms": "~1.8"
},
"autoload": {
"classmap": [
Expand Down
6 changes: 4 additions & 2 deletions src/Toplan/LaravelSms/SmsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class SmsManager
{
const VERSION = '2.6.2';
const VERSION = '2.6.3';

const STATE_KEY = '_state';

Expand Down Expand Up @@ -702,7 +702,7 @@ protected static function getStorageClassName()
if ($className && is_string($className)) {
return $className;
}
$middleware = config('laravel-sms.routeAttributes.middleware', null);
$middleware = config('laravel-sms.route.middleware', null);
if ($middleware === 'web' || (is_array($middleware) && in_array('web', $middleware))) {
return 'Toplan\Sms\SessionStorage';
}
Expand Down Expand Up @@ -875,6 +875,8 @@ protected static function getInterval()
/**
* 合成结果数组
*
* todo 改为抛出异常,然后在控制器中catch
*
* @param bool $pass
* @param string $type
* @param string $message
Expand Down
4 changes: 3 additions & 1 deletion src/Toplan/LaravelSms/SmsManagerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public function boot()
__DIR__ . '/../../../migrations/' => database_path('/migrations'),
], 'migrations');

require __DIR__ . '/routes.php';
if (config('laravel-sms.route.enable', true)) {
require __DIR__ . '/routes.php';
}

require __DIR__ . '/validations.php';

Expand Down
5 changes: 4 additions & 1 deletion src/Toplan/LaravelSms/routes.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?php

$routeAttr = config('laravel-sms.route', []);
unset($routeAttr['enable']);

$attributes = array_merge([
'prefix' => 'laravel-sms',
], config('laravel-sms.routeAttributes', []));
], $routeAttr);

Route::group($attributes, function () {
Route::get('info', 'Toplan\Sms\SmsController@getInfo');
Expand Down
13 changes: 7 additions & 6 deletions src/config/laravel-sms.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
return [
/*
|--------------------------------------------------------------------------
| 内置路由的属性
| 内置路由
|--------------------------------------------------------------------------
|
| 如果是web应用建议`middleware`为`web`
| 如果是api应用建议`middleware`为`api`
| 如果是 web 应用建议 middleware 为 ['web', ...]
| 如果是 api 应用建议 middleware 为 ['api', ...]
|
*/
'routeAttributes' => [
'route' => [
'enable' => true,
'prefix' => 'laravel-sms',
'middleware' => 'web',
'middleware' => ['web'],
],

/*
Expand Down Expand Up @@ -144,7 +145,7 @@
| driver:
| 存储方式,是一个实现了'Toplan\Sms\Storage'接口的类的类名,
| 内置可选的值有'Toplan\Sms\SessionStorage'和'Toplan\Sms\CacheStorage',
| 如果不填写driver,那么系统会自动根据内置路由的属性(routeAttributes)中middleware的配置值选择存储器driver:
| 如果不填写driver,那么系统会自动根据内置路由的属性(route)中middleware的配置值选择存储器driver:
| - 如果中间件含有'web',会选择使用'Toplan\Sms\SessionStorage'
| - 如果中间件含有'api',会选择使用'Toplan\Sms\CacheStorage'
|
Expand Down

0 comments on commit ef45fe2

Please sign in to comment.