Skip to content

Commit ee376a5

Browse files
author
Mark Horninger
committed
Added ServiceProvider
1 parent 121c71f commit ee376a5

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/**
3+
*/
4+
namespace Mhorninger\SQLite;
5+
/**
6+
* The Laravel ServiceProvider that initializes the MySQLite Connection.
7+
*/
8+
class MySQLiteServiceProvider extends \Illuminate\Support\ServiceProvider
9+
{
10+
/**
11+
* Bootstrap the application events.
12+
*
13+
* @return void
14+
*/
15+
public function boot()
16+
{
17+
Model::setConnectionResolver($this->app['db']);
18+
Model::setEventDispatcher($this->app['events']);
19+
}
20+
/**
21+
* Register the service provider.
22+
*
23+
* @return Connection connection
24+
*/
25+
public function register()
26+
{
27+
// Add database driver.
28+
$this->app->resolving(
29+
'db',
30+
function ($db) {
31+
$db->extend(
32+
'sqlite',
33+
function ($config, $name) {
34+
$config['name'] = $name;
35+
return new Connection($config);
36+
}
37+
);
38+
}
39+
);
40+
}
41+
}

0 commit comments

Comments
 (0)