首页 > 代码库 > 监听数据库查询语句

监听数据库查询语句

 

 

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);
        // });
    }

 

监听数据库查询语句