@@ -10,7 +10,7 @@ class ServiceProvider extends \Illuminate\Support\ServiceProvider
1010 CONFIG_PATH = __DIR__ . '/../config/laravel-firebase.php ' ;
1111
1212 protected
13- $ defer = false ;
13+ $ defer = false ;
1414
1515 public function boot ()
1616 {
@@ -27,33 +27,36 @@ public function register()
2727 );
2828
2929 // Provides the Firebase ServiceAccount
30- $ this ->app ->singleton (ServiceAccount::class,function ($ app ){
30+ $ this ->app ->singleton (ServiceAccount::class, function ($ app ) {
3131 $ sa = new ServiceAccount (config ('laravel-firebase.service_account ' ));
3232 // Add cache handler if cache is enabled
33- if (config ('laravel-firebase.cache ' )){
33+ if (config ('laravel-firebase.cache ' )) {
3434 $ sa ->setCacheHandler (new ServiceAccountCacheItemPool ());
3535 }
3636 return $ sa ;
3737 });
3838
3939 // Provide Firebase Database
40- $ this ->app ->singleton (Database::class,function ($ app ){
41- return (config ('laravel-firebase.read_only ' ))?
42- new ReadonlyDatabase ($ app ->make (ServiceAccount::class)):
43- new Database ($ app ->make (ServiceAccount::class));
40+ $ this ->app ->singleton (Database::class, function ($ app , array $ opt = []) {
41+ $ dbName = $ opt ['db ' ] ?? config ('laravel-firebase.default_db ' );
42+ $ dbUrl = config ('laravel-firebase.firebasedb_urls. ' . $ dbName );
43+
44+ return (config ('laravel-firebase.read_only ' )) ?
45+ new ReadonlyDatabase ($ app ->make (ServiceAccount::class), $ dbUrl ) :
46+ new Database ($ app ->make (ServiceAccount::class), $ dbUrl );
4447 });
4548
46- $ this ->app ->bind (FcmMessageBuilder::class,function ($ app ){
49+ $ this ->app ->bind (FcmMessageBuilder::class, function ($ app ) {
4750 $ fcm = new FcmMessageBuilder ($ app ->make (ServiceAccount::class));
4851
4952 $ event = config ('laravel-firebase.FCMInvalidTokenTriggerEvent ' );
50- if ($ event ){
53+ if ($ event ) {
5154 $ fcm ->setInvalidTokenEvent ($ event );
5255 }
5356 return $ fcm ;
5457 });
5558
56- $ this ->app ->singleton (JWT ::class,function ($ app ){
59+ $ this ->app ->singleton (JWT ::class, function ($ app ) {
5760 return new JWT ($ app ->make (ServiceAccount::class));
5861 });
5962 }
0 commit comments