Skip to content

Commit

Permalink
Fix provider resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
plokko committed Nov 26, 2023
1 parent fb5acac commit 40fe016
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/ReadonlyDatabase.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?php
namespace Plokko\LaravelFirebase;

use Plokko\Firebase\IO\Database;
use Plokko\Firebase\IO\Reference;

/**
* Wrapper of Plokko\Firebase\IO\Database that disabes write operations
* @package Plokko\LaravelFirebase
*/
class ReadonlyDatabase extends Database
class ReadonlyDatabase extends RealtimeDb
{

// Disable write functions
Expand All @@ -20,4 +19,4 @@ function getReference($path)
{
return new Reference($this,$path);
}
}
}
5 changes: 3 additions & 2 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ public function register()
});

// Provide Firebase Database
$this->app->singleton(Database::class, function ($app, array $opt = []) {
$this->app->singleton(Database::class, RealtimeDb::class);
$this->app->singleton(RealtimeDb::class, function ($app, array $opt = []) {
$dbName = $opt['db'] ?? config('laravel-firebase.default_db');
$dbUrl = config('laravel-firebase.firebasedb_urls.' . $dbName);

return (config('laravel-firebase.read_only')) ?
new ReadonlyDatabase($app->make(ServiceAccount::class), $dbUrl) :
new Database($app->make(ServiceAccount::class), $dbUrl);
new RealtimeDb($app->make(ServiceAccount::class), $dbUrl);
});

$this->app->bind(FcmMessageBuilder::class, function ($app) {
Expand Down

0 comments on commit 40fe016

Please sign in to comment.