@@ -55,9 +55,11 @@ public function edit(Model $model): Obj
55
55
return $ this ->template ;
56
56
}
57
57
58
- public function actions (string | array $ actions ): self
58
+ public function actions ($ actions ): self
59
59
{
60
- $ this ->template ->set ('actions ' , new Obj ($ this ->args ($ actions )));
60
+ $ args = Obj::wrap (is_string ($ actions ) ? func_get_args () : $ actions );
61
+
62
+ $ this ->template ->set ('actions ' , new Obj ($ args ));
61
63
62
64
return $ this ;
63
65
}
@@ -123,23 +125,23 @@ public function columns(string $field, int $value): self
123
125
return $ this ;
124
126
}
125
127
126
- public function hide (string | array $ fields ): self
128
+ public function hide ($ fields ): self
127
129
{
128
- $ this -> collection ( $ fields )
130
+ Collection:: wrap ( is_string ( $ fields ) ? func_get_args () : $ fields )
129
131
->each (fn ($ field ) => $ this ->field ($ field )
130
132
->get ('meta ' )->set ('hidden ' , true ));
131
133
132
134
return $ this ;
133
135
}
134
136
135
- public function hideSection (string | array $ fields ): self
137
+ public function hideSection ($ fields ): self
136
138
{
137
139
$ this ->sectionVisibility ($ fields , $ hidden = true );
138
140
139
141
return $ this ;
140
142
}
141
143
142
- public function showSection (string | array $ fields ): self
144
+ public function showSection ($ fields ): self
143
145
{
144
146
$ this ->sectionVisibility ($ fields , $ hidden = false );
145
147
@@ -160,27 +162,27 @@ public function showTab($tabs): self
160
162
return $ this ;
161
163
}
162
164
163
- public function show (string | array $ fields ): self
165
+ public function show ($ fields ): self
164
166
{
165
- $ this -> collection ( $ fields )
167
+ Collection:: wrap ( is_string ( $ fields ) ? func_get_args () : $ fields )
166
168
->each (fn ($ field ) => $ this ->field ($ field )
167
169
->get ('meta ' )->set ('hidden ' , false ));
168
170
169
171
return $ this ;
170
172
}
171
173
172
- public function disable (string | array $ fields ): self
174
+ public function disable ($ fields ): self
173
175
{
174
- $ this -> collection ( $ fields )
176
+ Collection:: wrap ( is_string ( $ fields ) ? func_get_args () : $ fields )
175
177
->each (fn ($ field ) => $ this ->field ($ field )
176
178
->get ('meta ' )->set ('disabled ' , true ));
177
179
178
180
return $ this ;
179
181
}
180
182
181
- public function readonly (string | array $ fields ): self
183
+ public function readonly ($ fields ): self
182
184
{
183
- $ this -> collection ( $ fields )
185
+ Collection:: wrap ( is_string ( $ fields ) ? func_get_args () : $ fields )
184
186
->each (fn ($ field ) => $ this ->field ($ field )
185
187
->get ('meta ' )->set ('readonly ' , true ));
186
188
@@ -226,17 +228,17 @@ public function labels(bool $labels): self
226
228
return $ this ;
227
229
}
228
230
229
- public function sectionVisibility (string | array $ fields , bool $ hidden ): self
231
+ public function sectionVisibility ($ fields , bool $ hidden ): self
230
232
{
231
- $ this -> collection ( $ fields )
233
+ Collection:: wrap ( is_string ( $ fields ) ? func_get_args () : $ fields )
232
234
->each (fn ($ field ) => $ this ->section ($ field )->put ('hidden ' , $ hidden ));
233
235
234
236
return $ this ;
235
237
}
236
238
237
- public function tabVisibility (string | array $ tabs , bool $ hidden ): self
239
+ public function tabVisibility ($ tabs , bool $ hidden ): self
238
240
{
239
- $ tabs = $ this -> collection ( $ tabs );
241
+ $ tabs = Collection:: wrap ( is_string ( $ tabs ) ? func_get_args () : $ tabs );
240
242
241
243
$ this ->template ->get ('sections ' )->each (fn ($ section ) => $ tabs ->when (
242
244
$ tabs ->contains ($ section ->get ('tab ' )),
@@ -310,14 +312,4 @@ private function needsValidation(): bool
310
312
311
313
return in_array ($ validations , [App::environment (), 'always ' ]);
312
314
}
313
-
314
- private function collection (string | array $ fields ): Collection
315
- {
316
- return new Collection ($ this ->args ($ fields ));
317
- }
318
-
319
- private function args (string | array $ args ): array
320
- {
321
- return is_string ($ args ) ? func_get_args () : $ args ;
322
- }
323
315
}
0 commit comments