File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed
Expand file tree Collapse file tree 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+ }
Original file line number Diff line number Diff line change 33namespace Native \Laravel ;
44
55use Native \Laravel \Client \Client ;
6+ use Native \Laravel \DataObjects \Printer ;
67
78class System
89{
@@ -21,4 +22,31 @@ public function promptTouchID(string $reason): bool
2122 'reason ' => $ reason ,
2223 ])->successful ();
2324 }
25+
26+ /**
27+ * @return array<\Native\Laravel\DataObjects\Printer>
28+ */
29+ public function printers (): array
30+ {
31+ $ printers = $ this ->client ->get ('system/printers ' )->json ('printers ' );
32+
33+ return collect ($ printers )->map (function ($ printer ) {
34+ return new Printer (
35+ data_get ($ printer , 'name ' ),
36+ data_get ($ printer , 'displayName ' ),
37+ data_get ($ printer , 'description ' ),
38+ data_get ($ printer , 'status ' ),
39+ data_get ($ printer , 'isDefault ' ),
40+ data_get ($ printer , 'options ' ),
41+ );
42+ })->toArray ();
43+ }
44+
45+ public function print (string $ html , Printer $ printer = null ): void
46+ {
47+ $ this ->client ->post ('system/print ' , [
48+ 'html ' => $ html ,
49+ 'printer ' => $ printer ->name ?? '' ,
50+ ]);
51+ }
2452}
You can’t perform that action at this time.
0 commit comments