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+ }
18+ }
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,30 @@ 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+ 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+ }
2451}
You can’t perform that action at this time.
0 commit comments