监听数据库查询语句

 

 

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Validator;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        // validator extend phone
        Validator::extend('phone', function ($attribute, $value, $parameters) {
            if (preg_match('/^170/', $value)) {
                return false;
            }
            if (preg_match('/^1(3[0-9]|4[0-9]|5[012356789]|8[01256789]|7[0678])\d{8}$/', $value)) {
                return true;
            }

            return false;
        }, '手机号不正确');

        // \DB::listen(function($query) {
        //     \Log::info($query->sql);
        // });
    }

 

posted @ 2017-06-09 10:23  洪先森  阅读(517)  评论(0编辑  收藏  举报