Skip to content

Commit ff7bdfe

Browse files
committed
wip
1 parent f9d49aa commit ff7bdfe

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Native\Laravel\Events\Settings;
4+
5+
use Illuminate\Broadcasting\Channel;
6+
use Illuminate\Broadcasting\InteractsWithSockets;
7+
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
8+
use Illuminate\Foundation\Events\Dispatchable;
9+
use Illuminate\Queue\SerializesModels;
10+
11+
class SettingChanged implements ShouldBroadcastNow
12+
{
13+
use Dispatchable, InteractsWithSockets, SerializesModels;
14+
15+
public function __construct(public string $key, public mixed $value)
16+
{
17+
18+
}
19+
20+
public function broadcastOn()
21+
{
22+
return [
23+
new Channel('nativephp'),
24+
];
25+
}
26+
}

src/Facades/Settings.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Native\Laravel\Facades;
4+
5+
use Illuminate\Support\Facades\Facade;
6+
7+
class Settings extends Facade
8+
{
9+
protected static function getFacadeAccessor()
10+
{
11+
return \Native\Laravel\Settings::class;
12+
}
13+
}

src/Settings.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Native\Laravel;
4+
5+
use Native\Laravel\Client\Client;
6+
7+
class Settings
8+
{
9+
public function __construct(protected Client $client)
10+
{
11+
}
12+
13+
public function set($key, $value): void
14+
{
15+
$this->client->post('settings/'.$key, [
16+
'value' => $value,
17+
]);
18+
}
19+
20+
public function get($key, $default = null): mixed
21+
{
22+
return $this->client->get('settings/'.$key)->json('value') ?? $default;
23+
}
24+
}

0 commit comments

Comments
 (0)