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 2525 "larastan/larastan" : " ^2.9.1" ,
2626 "orchestra/testbench" : " ^9" ,
2727 "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."
2933 },
3034 "autoload" : {
3135 "psr-4" : {
Original file line number Diff line number Diff line change 88use Illuminate \Support \Fluent ;
99use Illuminate \Support \Traits \Macroable ;
1010use InvalidArgumentException ;
11+ use Livewire \Livewire ;
1112use Throwable ;
1213use Yajra \DataTables \Html \Enums \LayoutPosition ;
1314
@@ -118,6 +119,27 @@ public function addView(
118119 return $ this ;
119120 }
120121
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+
121143 private function renderCustomElement (string $ element , bool $ asJsSelector = true ): string
122144 {
123145 $ html = $ asJsSelector ? "$(' {$ element }').html() " : $ element ;
You can’t perform that action at this time.
0 commit comments