🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
参考文章 https://www.cnblogs.com/meng1314-shuai/p/7232080.html #### 1. bootstrap/app.php ```php $app->register(App\Providers\EventServiceProvider::class); ``` #### 2. app/Providers/EventServiceProvier.php ```php <?php namespace App\Providers; use Illuminate\Database\Events\StatementPrepared; use Laravel\Lumen\Providers\EventServiceProvider as ServiceProvider; class EventServiceProvider extends ServiceProvider { /** * The event listener mappings for the application. * * @var array */ protected $listen = [ 'App\Events\SomeEvent' => [ 'App\Listeners\EventListener', ], ]; public function boot() { app('events')->listen(StatementPrepared::class, function ($event) { $event->statement->setFetchMode(\PDO::FETCH_ASSOC); }); } } ```