File tree 2 files changed +45
-0
lines changed 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Native \Laravel \DataObjects ;
4
+
5
+ class Printer
6
+ {
7
+ public function __construct (
8
+ public string $ name ,
9
+ public string $ displayName ,
10
+ public string $ description ,
11
+ public int $ status ,
12
+ public bool $ isDefault ,
13
+ public array $ options
14
+ )
15
+ {
16
+
17
+ }
18
+ }
Original file line number Diff line number Diff line change 3
3
namespace Native \Laravel ;
4
4
5
5
use Native \Laravel \Client \Client ;
6
+ use Native \Laravel \DataObjects \Printer ;
6
7
7
8
class System
8
9
{
@@ -21,4 +22,30 @@ public function promptTouchID(string $reason): bool
21
22
'reason ' => $ reason ,
22
23
])->successful ();
23
24
}
25
+
26
+ /**
27
+ * @return array<\Native\Laravel\DataObjects\Printer>
28
+ */
29
+ public function printers (): ar
8000
ray
30
+ {
31
+ $ printers = $ this ->client ->get ('system/printers ' )->json ('printers ' );
32
+ return collect ($ printers )->map (function ($ printer ) {
33
+ return new Printer (
34
+ data_get ($ printer , 'name ' ),
35
+ data_get ($ printer , 'displayName ' ),
36
+ data_get ($ printer , 'description ' ),
37
+ data_get ($ printer , 'status ' ),
38
+ data_get ($ printer , 'isDefault ' ),
39
+ data_get ($ printer , 'options ' ),
40
+ );
41
+ })->toArray ();
42
+ }
43
+
44
+ public function print (string $ html , Printer $ printer = null ): void
45
+ {
46
+ $ this ->client ->post ('system/print ' , [
47
+ 'html ' => $ html ,
48
+ 'printer ' => $ printer ->name ?? '' ,
49
+ ]);
50
+ }
24
51
}
You can’t perform that action at this time.
0 commit comments