1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ikechukwukalu\Dynamicdatabaseconfig; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use Ikechukwukalu\Dynamicdatabaseconfig\Console\Commands\DynamicDatabaseConfigMigrateCommand; |
7
|
|
|
use Ikechukwukalu\Dynamicdatabaseconfig\Console\Commands\EnvDatabaseConfigMigrateCommand; |
8
|
|
|
use Ikechukwukalu\Dynamicdatabaseconfig\Console\Commands\DynamicDatabaseConfigSeedCommand; |
9
|
|
|
use Ikechukwukalu\Dynamicdatabaseconfig\Console\Commands\EnvDatabaseConfigSeedCommand; |
10
|
|
|
use Ikechukwukalu\Dynamicdatabaseconfig\Middleware\DynamicDatabaseConfig; |
11
|
|
|
use Ikechukwukalu\Dynamicdatabaseconfig\Middleware\EnvDatabaseConfig; |
12
|
|
|
use Illuminate\Support\ServiceProvider; |
13
|
|
|
use Illuminate\Routing\Router; |
14
|
|
|
|
15
|
|
|
class DynamicDatabaseConfigServiceProvider extends ServiceProvider |
16
|
|
|
{ |
17
|
|
|
public const DB = __DIR__.'/migrations'; |
18
|
|
|
public const CONFIG = __DIR__.'/config/dynamicdatabaseconfig.php'; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Bootstrap the application services. |
22
|
|
|
* |
23
|
|
|
* @return void |
24
|
|
|
*/ |
25
|
|
|
public function boot() |
26
|
|
|
{ |
27
|
|
|
if ($this->app->runningInConsole()) { |
|
|
|
|
28
|
|
|
$this->commands([ |
|
|
|
|
29
|
|
|
DynamicDatabaseConfigMigrateCommand::class, |
30
|
|
|
EnvDatabaseConfigMigrateCommand::class, |
31
|
|
|
DynamicDatabaseConfigSeedCommand::class, |
32
|
|
|
EnvDatabaseConfigSeedCommand::class |
33
|
|
|
]); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
$router = $this->app->make(Router::class); |
|
|
|
|
37
|
|
|
$router->aliasMiddleware('dynamic.database.config', DynamicDatabaseConfig::class); |
38
|
|
|
$router->aliasMiddleware('env.database.config', EnvDatabaseConfig::class); |
39
|
|
|
|
40
|
|
|
$this->loadMigrationsFrom(self::DB); |
|
|
|
|
41
|
|
|
|
42
|
|
|
$this->publishes([ |
|
|
|
|
43
|
|
|
self::CONFIG => config_path('dynamicdatabaseconfig.php'), |
44
|
|
|
], 'ddc-config'); |
45
|
|
|
|
46
|
|
|
$this->publishes([ |
47
|
|
|
self::DB => database_path('migrations'), |
48
|
|
|
], 'ddc-migrations'); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Register the application services. |
53
|
|
|
* |
54
|
|
|
* @return void |
55
|
|
|
*/ |
56
|
|
|
public function register() |
57
|
|
|
{ |
58
|
|
|
$this->mergeConfigFrom( |
|
|
|
|
59
|
|
|
self::CONFIG, 'dynamicdatabaseconfig' |
60
|
|
|
); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.