File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 25
25
"larastan/larastan" : " ^2.9.1" ,
26
26
"orchestra/testbench" : " ^9" ,
27
27
"laravel/pint" : " ^1.14" ,
28
- "rector/rector" : " ^1.0"
28
+ "rector/rector" : " ^1.0" ,
29
+ "livewire/livewire" : " ^3.4"
30
+ },
31
+ "suggest" : {
32
+ "laravel/livewire" : " Required for Livewire layout support."
29
33
},
30
34
"autoload" : {
31
35
"psr-4" : {
Original file line number Diff line number Diff line change 8
8
use Illuminate \Support \Fluent ;
9
9
use Illuminate \Support \Traits \Macroable ;
10
10
use InvalidArgumentException ;
11
+ use Livewire \Livewire ;
11
12
use Throwable ;
12
13
use Yajra \DataTables \Html \Enums \LayoutPosition ;
13
14
@@ -118,6 +119,27 @@ public function addView(
118
119
return $ this ;
119
120
}
120
121
122
+ /**
123
+ * @param class-string $component
124
+ *
125
+ * @throws Throwable
126
+ */
127
+ public function addLivewire (
128
+ string $ component ,
129
+ LayoutPosition $ layoutPosition ,
130
+ ?int $ order = null
131
+ ): static {
132
+ $ html = json_encode (Livewire::mount ($ component ));
133
+
134
+ if ($ html === false ) {
135
+ throw new InvalidArgumentException ("Cannot render Livewire component [ $ component] to json. " );
136
+ }
137
+
138
+ $ this ->attributes [$ layoutPosition ->withOrder ($ order )] = $ this ->renderCustomElement ($ html , false );
139
+
140
+ return $ this ;
141
+ }
142
+
121
143
private function renderCustomElement (string $ element , bool $ asJsSelector = true ): string
122
144
{
123
145
$ html = $ asJsSelector ? "$(' {$ element }').html() " : $ element ;
You can’t perform that action at this time.
0 commit comments