@@ -11,17 +11,48 @@ Install @zeus Qr by running the following commands in your Laravel project direc
11
11
composer require lara-zeus/qr
12
12
```
13
13
14
+ ## Migration
15
+
16
+ Make sure to edit your resource migration to add the required columns.
17
+ The main one will be the same as your component; in the example below, it is set as ` qr_code ` .
18
+ If you want to store the personalization, another column is required; in the example, it is ` options ` .
19
+
20
+ ``` php
21
+ Schema::create('ticket_replies', function (Blueprint $table) {
22
+ // other columns
23
+ $table->string('qr_code');
24
+ $table->text('options');
25
+ // other columns
26
+ });
27
+ ```
28
+
29
+ ## Cast
30
+
31
+ The personalizations are stored as string but the component will use it as array so you need to tell to your model to cast it as array.
32
+
33
+ ``` php
34
+ class QrCode extends Model
35
+ {
36
+ use HasFactory;
37
+
38
+ protected $casts = [
39
+ 'options' => 'array'
40
+ ];
41
+ }
42
+ ```
43
+
14
44
## Usage:
15
45
16
46
use it in your resource
17
47
18
48
``` php
19
49
\LaraZeus\Qr\Components\Qr::make('qr_code')
20
- // to open the designer as slide over instead of a modal
50
+ // to open the designer as slide over instead of a modal.
51
+ // Comment it out if you prefer the modal.
21
52
->asSlideOver()
22
53
23
- //you can set the column you want to save the QR design options, you must cast it to array in your model
24
- ->optionsColumn('string ')
54
+ // you can set the column you want to save the QR design options, you must cast it to array in your model
55
+ ->optionsColumn('options ')
25
56
26
57
// set the icon for the QR action
27
58
->actionIcon('heroicon-s-building-library')
@@ -64,6 +95,18 @@ PopoverEntry::make('name')
64
95
->content(\LaraZeus\Qr\Facades\Qr::render(data:'dataOrUrl')),
65
96
```
66
97
98
+ If you just want to print the QrCode in the InfoList you can use TextEntry with ` formatStateUsing ` method and pass the state and the $record as params.
99
+
100
+ ``` php
101
+ TextEntry::make('qr_code')
102
+ ->formatStateUsing(function (string $state, $record) {
103
+ return \LaraZeus\Qr\Facades\Qr::render(
104
+ data: $state,
105
+ options: $record->options // This is your model. We are passing the personalizations. If you want the default just comment it out.
106
+ );
107
+ }),
108
+ ```
109
+
67
110
### Usage with any action
68
111
69
112
to use the QR code as an action in anywhere you want:
0 commit comments