Skip to content

Commit 572a4b0

Browse files
committed
add config
1 parent 5d129a5 commit 572a4b0

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

config/sqlite-functions.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
return [
4+
'driver_to_mimic' => 'mysql',
5+
];

src/ServiceProvider.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,29 @@
66

77
class ServiceProvider extends BaseProvider
88
{
9+
/**
10+
* Bootstrap the package.
11+
*/
912
public function boot()
1013
{
11-
if ($this->app->environment('testing') && $this->app['db']->getDriverName() == 'sqlite') {
12-
(new FunctionRegistrar)->register($this->app['db']->getPdo(), $this->app['db']->getDefaultConnection());
13-
}
14-
}
14+
if ($this->app->runningInConsole()) {
15+
$this->publishes([
16+
__DIR__.'/../config/sqlite-functions.php' => $this->app->configPath(),
17+
]);
18+
}
19+
20+
$this->mergeConfigFrom(__DIR__.'/../config/sqlite-functions.php');
21+
22+
$this->registerFunctions();
23+
}
24+
25+
/**
26+
* Register the functions.
27+
*/
28+
protected function registerFunctions(): void
29+
{
30+
if ($this->app->environment('testing') && $this->app['db']->getDriverName() == 'sqlite') {
31+
(new FunctionRegistrar)->register($this->app['db']->getPdo(), config('sqlite-functions.driver_to_mimic'));
32+
}
33+
}
1534
}

0 commit comments

Comments
 (0)