Skip to content

Commit 26109e1

Browse files
Mark Horningerspam-n-eggs
authored andcommitted
Corrected issues with ServiceProvider (#3)
* Pulling in changes from @spam-n-eggs (#1) * Corrected issues with the resolver that were throwing errors.
1 parent 14e8970 commit 26109e1

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

src/Mhorninger/SQLite/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use Mhorninger\MySQLite\MySQLite;
55

66

7-
class Connection extends \Illuminate\Database\Connection
7+
class Connection extends \Illuminate\Database\SQLiteConnection
88
{
99
/**
1010
* Create a new database connection instance.
Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?php
22
namespace Mhorninger\SQLite;
33

4-
use Illuminate\Database\Eloquent\Model;
4+
use Illuminate\Database\Connectors\SQLiteConnector;
5+
use \PDO;
6+
use Illuminate\Database\Connection;
57

68
/**
79
* The Laravel ServiceProvider that initializes the MySQLite Connection.
@@ -10,33 +12,21 @@ class MySQLiteServiceProvider extends \Illuminate\Support\ServiceProvider
1012
{
1113
/**
1214
* Bootstrap the application events.
13-
*
15+
*
1416
* @return void
1517
*/
1618
public function boot()
1719
{
18-
Model::setConnectionResolver($this->app['db']);
19-
Model::setEventDispatcher($this->app['events']);
2020
}
2121
/**
2222
* Register the service provider.
23-
*
23+
*
2424
* @return Connection connection
2525
*/
2626
public function register()
2727
{
28-
// Add database driver.
29-
$this->app->resolving(
30-
'db',
31-
function ($db) {
32-
$db->extend(
33-
'sqlite',
34-
function ($config, $name) {
35-
$config['name'] = $name;
36-
return new Connection($config);
37-
}
38-
);
39-
}
40-
);
41-
}
28+
Connection::resolverFor('sqlite', function ($connection, $database, $prefix, $config) {
29+
return new Connection($connection, $database, $prefix, $config);
30+
});
31+
}
4232
}

0 commit comments

Comments
 (0)