Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 4095f8b

Browse files
ctf0ctf0
authored andcommitted
update drivers
1 parent f70250d commit 4095f8b

File tree

4 files changed

+22
-33
lines changed

4 files changed

+22
-33
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1 @@
1-
# These are supported funding model platforms
2-
3-
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4-
patreon: ctf0
5-
open_collective: # Replace with a single Open Collective username
6-
ko_fi: # Replace with a single Ko-fi username
7-
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8-
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9-
liberapay: # Replace with a single Liberapay username
10-
issuehunt: # Replace with a single IssueHunt username
11-
otechie: # Replace with a single Otechie username
12-
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
1+
github: ctf0

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"illuminate/support": ">=5.5 <9.0",
19+
"illuminate/support": ">=5.5 <10.0",
2020
"kreait/firebase-php": "*"
2121
},
2222
"suggest": {
@@ -45,8 +45,8 @@
4545
},
4646
"funding": [
4747
{
48-
"type": "patreon",
49-
"url": "https://www.patreon.com/ctf0"
48+
"type": "github",
49+
"url": "https://github.com/sponsors/ctf0"
5050
}
5151
]
5252
}

src/Broadcasters/FSDB.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
use Illuminate\Support\Arr;
66
use Illuminate\Support\Str;
7-
use Kreait\Firebase\ServiceAccount;
8-
use Morrislaptop\Firestore\Factory;
7+
use Kreait\Firebase\Factory;
98
use Kreait\Firebase\Exception\ApiException;
109
use Illuminate\Broadcasting\BroadcastException;
1110
use Illuminate\Broadcasting\Broadcasters\Broadcaster;
@@ -15,18 +14,20 @@ class FSDB extends Broadcaster
1514
use Common;
1615

1716
protected $db;
17+
1818
protected $config;
1919

2020
/**
2121
* Create a new broadcaster instance.
22+
*
23+
* @param mixed $config
2224
*/
2325
public function __construct($config)
2426
{
25-
$sr_account = ServiceAccount::fromJsonFile(base_path($config['creds_file']));
2627
$this->config = $config;
2728
$this->db = (new Factory())
28-
->withServiceAccount($sr_account)
29-
->createFirestore();
29+
->withServiceAccount($config['creds_file'])
30+
->createDatabase();
3031
}
3132

3233
/**
@@ -35,11 +36,11 @@ public function __construct($config)
3536
public function broadcast(array $channels, $event, array $payload = [])
3637
{
3738
$db = $this->db;
39+
$coll = $db->collection($this->config['collection_name']);
3840
$socket = Arr::pull($payload, 'socket');
3941

4042
foreach ($this->formatChannels($channels) as $channel) {
4143
try {
42-
$coll = $db->collection($this->config['collection_name']);
4344
$doc = $coll->document(md5(Str::uuid()));
4445
$doc->set([
4546
'channel' => $channel,

src/Broadcasters/RTDB.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,29 @@ class RTDB extends Broadcaster
2424
public function __construct($config)
2525
{
2626
$this->config = $config;
27-
$factory = (new Factory())
27+
$this->db = (new Factory())
2828
->withServiceAccount(base_path($config['creds_file']))
29-
->withDatabaseUri($config['databaseURL']);
30-
31-
$this->db = $factory->createDatabase();
29+
->withDatabaseUri($config['databaseURL'])
30+
->createDatabase();
3231
}
3332

3433
/**
3534
* {@inheritdoc}
3635
*/
3736
public function broadcast(array $channels, $event, array $payload = [])
3837
{
38+
$db = $this->db->getReference($this->config['collection_name']);
3939
$socket = Arr::pull($payload, 'socket');
4040

4141
foreach ($this->formatChannels($channels) as $channel) {
4242
try {
43-
$this->db->getReference($this->config['collection_name'])
44-
->push([
45-
'channel' => $channel,
46-
'data' => $payload,
47-
'event' => $event,
48-
'socket' => $socket,
49-
'timestamp' => round(now()->valueOf()), // return date == to js Date.now()
50-
]);
43+
$db->push([
44+
'channel' => $channel,
45+
'data' => $payload,
46+
'event' => $event,
47+
'socket' => $socket,
48+
'timestamp' => round(now()->valueOf()), // return date == to js Date.now()
49+
]);
5150
} catch (ApiException $e) {
5251
throw new BroadcastException($e);
5352
}

0 commit comments

Comments
 (0)