csuilong / luosimao-captcha
Luosimao Validator for Laravel 5 能用的我更新过了
V2.0.1
2018-01-27 17:09 UTC
Requires
- php: >=5.4.0
- illuminate/support: ~5.1
This package is not auto-updated.
Last update: 2024-11-10 05:49:15 UTC
README
A Luosimao Validator for Laravel 5.
Installation
Add the following line to the require
section of composer.json
:
"require": { "pokeguys/laravel-luosimao-captcha": "dev-master" }
Setup
- In
/config/app.php
, add the following toproviders
:
'providers' => [ // Other Service Providers Pokeguys\Luosimao\LuosimaoServiceProvider::class, ],
and the following to aliases
:
'aliases' => [ // Other Aliases 'Luosimao' => Pokeguys\Luosimao\Facades\Luosimao::class, ],
- Run
php artisan vendor:publish --provider="Pokeguys\Luosimao\LuosimaoServiceProvider"
. - In
/config/luosimao.php
, enter your Luosimao public and private keys. - The package ships with a default validation message, but if you want to customize it, add the following line into
resources/lang/[lang]/validation.php
:
[ // Other validation message 'luosimao' => 'The :attribute field is not correct.', ]
Usage
In your validation rules, add the following:
$rules = [ // ... 'luosimao' => 'required|luosimao', ];
$this->validate($request,[ 'luotest_response' => 'required|luosimao', ],[ 'luotest_response.required' => '请点按验证码!', 'luotest_response.luosimao' => '验证码错误,请重试。', ]);
It's also recommended to add required
when validating.