Skip to content

Commit

Permalink
Remove unused value in turso database configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
richan-fongdasen committed Nov 13, 2024
1 parent 0ce0a8b commit 1380f94
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
20 changes: 9 additions & 11 deletions src/TursoLaravelServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
});
}
}
1 change: 0 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 1380f94

Please sign in to comment.