[李景山php]每天laravel-20161001|ValidationServiceProvider.php
2016-07-28 09:02
567 查看
<?php namespace Illuminate\Validation; use Illuminate\Support\ServiceProvider; // just namespace class ValidationServiceProvider extends ServiceProvider {// a class extends a standard class /** * Indicates if loading of the provider is deferred. * * @var bool */ protected $defer = true;// Indicates if loading of the provider is deferred. /** * Register the service provider. * * @return void */ public function register() { $this->registerPresenceVerifier();// register Presence Verifier $this->registerValidationFactory();// register validation Factory }// Register the service provider. /** * Register the validation factory. * * @return void */ protected function registerValidationFactory() { $this->app->singleton('validator', function ($app) { $validator = new Factory($app['translator'], $app);// get instance of the // The validation presence verifier is responsible for determining the existence // of values in a given data collection, typically a relational database or // other persistent data stores. And it is used to check for uniqueness. if (isset($app['validation.presence'])) {// has it $validator->setPresenceVerifier($app['validation.presence']);//and set it }// if has a other way to get it return $validator;// return it });// set the singleton }// Register the validation factory. /** * Register the database presence verifier. * * @return void */ protected function registerPresenceVerifier() { $this->app->singleton('validation.presence', function ($app) { return new DatabasePresenceVerifier($app['db']); });// like set a singleton }//Register the database presence verifier. /** * Get the services provided by the provider. * * @return array */ public function provides() { return [ 'validator', 'validation.presence', ]; }// get return }
相关文章推荐
- yii2的urlManager配置
- php中创建文件函数tempnam()与tmpfile()区别
- 如何提高php性能2
- 如何提高php性能1
- 浅谈PHP弱类型安全
- Laravel框架数据库CURD操作、连贯操作总结
- The Non-Inverting Amplifier Output Resistance by Adrian S. Nastase [转载]
- php中字符串函数
- php数组函数
- php中自带的内置函数
- PHP 笔记
- PHP基础之 file_get_contents() 函数
- Yii2.0 ajax多条件搜索 返回json数据格式
- 使用Thinkphp小结1,增删改查
- php基础之 ->, =>,@,&,::,%符号
- PHP学习 Class two
- PHP基础之 define() 函数
- thinkPHP入门 一
- lareval操作
- thinkPHP中服务器端的验证