File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change 1111
1212class ClickHouseServiceProvider extends ServiceProvider
1313{
14+ /**
15+ * @return void
16+ */
1417 public function boot (): void
1518 {
16- /** @var DatabaseManager $db */
17- $ db = $ this ->app ->get ('db ' );
19+ $ this ->app ->resolving ('db ' , function ($ db ) {
20+ $ db ->extend ('clickhouse-ext ' , function ($ config , $ name ) {
21+ $ config ['name ' ] = $ name ;
22+ $ connection = new Connection ($ config );
23+ if ($ this ->app ->bound ('events ' )) {
24+ $ connection ->setEventDispatcher ($ this ->app ['events ' ]);
25+ }
1826
19- $ db ->extend ('clickhouse-ext ' , function ($ config , $ name ) {
20- $ config ['name ' ] = $ name ;
21- $ connection = new Connection ($ config );
22- if ($ this ->app ->bound ('events ' )) {
23- $ connection ->setEventDispatcher ($ this ->app ['events ' ]);
24- }
27+ return $ connection ;
28+ });
2529
26- return $ connection ;
30+ Model:: setConnectionResolver ( $ db ) ;
2731 });
28-
29- Model::setConnectionResolver ($ db );
3032 }
3133}
You can’t perform that action at this time.
0 commit comments