environment('production')) { $this->app->bind( 'Illuminate\Contracts\Foundation\ExceptionRenderer', fn ($app) => $app->make(\App\RSpade\Integrations\Jqhtml\JqhtmlExceptionRenderer::class) ); } // Configure MySQL connection to use custom grammar with millisecond precision $connection = DB::connection(); if ($connection->getDriverName() === 'mysql') { $connection->setQueryGrammar(new \App\RSpade\Core\Database\Query\Grammars\Query_MySqlGrammar()); $connection->setSchemaGrammar(new \App\RSpade\Core\Database\Schema\Grammars\Schema_MySqlGrammar()); } // Set up query listener for migration/normalize debugging DB::listen(function ($query) { if (self::$query_log_mode === self::QUERY_LOG_NONE) { return; } $sql = $query->sql; $is_destructive = self::is_destructive_query($sql); switch (self::$query_log_mode) { case self::QUERY_LOG_ALL_STDOUT: echo $sql . "\n"; break; case self::QUERY_LOG_DESTRUCTIVE_STDOUT: if ($is_destructive) { echo $sql . "\n"; } break; case self::QUERY_LOG_ALL_LARAVEL: Log::debug('SQL Query: ' . $sql); break; case self::QUERY_LOG_DESTRUCTIVE_LARAVEL: if ($is_destructive) { Log::debug('SQL Query (Destructive): ' . $sql); } break; } }); // Share $errors variable with all views for @error directive // Disabled for custom session handler // View::composer('*', function ($view) { // $view->with('errors', session()->get('errors', new ViewErrorBag)); // }); // Register custom database session handler to preserve user_id and site_id columns // Disabled for custom session handler // Session::extend('database', function ($app) { // $connection = $app['db']->connection($app['config']['session.connection']); // $table = $app['config']['session.table']; // $lifetime = $app['config']['session.lifetime']; // // return new \App\RSpade\Core\Session\Custom_DatabaseSessionHandler( // $connection, // $table, // $lifetime, // $app // ); // }); // Override cache:clear to integrate RSX clearing if ($this->app->runningInConsole()) { $this->override_cache_clear(); } } /** * Override Laravel's cache:clear command to integrate with RSX * * @return void */ protected function override_cache_clear() { // Only override cache:clear to also clear RSX caches $this->app->extend('command.cache.clear', function ($command, $app) { return new \App\Console\Commands\CacheClearCommand(); }); } }