From 1380f947c667a0a355b7769a6736197aa6a3851a Mon Sep 17 00:00:00 2001 From: Richan Fongdasen Date: Wed, 13 Nov 2024 19:40:59 +0700 Subject: [PATCH] Remove unused value in turso database configuration --- README.md | 1 - src/TursoLaravelServiceProvider.php | 20 +++++++++----------- tests/TestCase.php | 1 - 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 17bc9a8..c05be4b 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,6 @@ To use Turso as your database driver in Laravel, append the following configurat 'db_url' => env('DB_URL', 'http://localhost:8080'), 'access_token' => env('DB_ACCESS_TOKEN'), 'db_replica' => env('DB_REPLICA'), - 'database' => null, // Leave this null 'prefix' => env('DB_PREFIX', ''), 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), 'sticky' => env('DB_STICKY', true), diff --git a/src/TursoLaravelServiceProvider.php b/src/TursoLaravelServiceProvider.php index 858bad6..d6b7112 100644 --- a/src/TursoLaravelServiceProvider.php +++ b/src/TursoLaravelServiceProvider.php @@ -4,8 +4,7 @@ namespace RichanFongdasen\Turso; -use Illuminate\Database\Connection; -use Illuminate\Database\DatabaseManager; +use Illuminate\Support\Facades\DB; use RichanFongdasen\Turso\Commands\TursoSyncCommand; use RichanFongdasen\Turso\Database\TursoConnection; use RichanFongdasen\Turso\Database\TursoConnector; @@ -49,18 +48,17 @@ public function register(): void return new TursoManager(); }); - $this->app->extend(DatabaseManager::class, function (DatabaseManager $manager) { - Connection::resolverFor('turso', function ($connection = null, ?string $database = null, string $prefix = '', array $config = []) { - $connector = new TursoConnector(); - $pdo = $connector->connect($config); + DB::extend('turso', function (array $config, string $name) { + $config['database'] = null; + $config['name'] = $name; - $connection = new TursoConnection($pdo, $database ?? 'turso', $prefix, $config); - $connection->createReadPdo($config); + $connector = new TursoConnector(); + $pdo = $connector->connect($config); - return $connection; - }); + $connection = new TursoConnection($pdo, $config['name'], $config['prefix'], $config); + $connection->createReadPdo($config); - return $manager; + return $connection; }); } } diff --git a/tests/TestCase.php b/tests/TestCase.php index b21239b..d87e272 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -30,7 +30,6 @@ public function getEnvironmentSetUp($app) 'driver' => 'turso', 'db_url' => env('DB_URL', 'http://127.0.0.1:8080'), 'db_replica' => env('DB_REPLICA'), - 'database' => null, 'prefix' => env('DB_PREFIX', ''), 'access_token' => 'your-access-token', 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),