File tree 3 files changed +63
-0
lines changed
3 files changed +63
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments