This repository was archived by the owner on Mar 18, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 4
4
5
5
namespace Rawilk \FormComponents ;
6
6
7
+ use Illuminate \Support \Arr ;
7
8
use Illuminate \Support \Facades \Blade ;
8
9
use Illuminate \Support \Facades \Route ;
9
10
use Illuminate \Support \ServiceProvider ;
@@ -102,6 +103,26 @@ private function bootMacros(): void
102
103
ComponentAttributeBag::macro ('hasStartsWith ' , function ($ key ) {
103
104
return (bool ) $ this ->whereStartsWith ($ key )->first ();
104
105
});
106
+
107
+ // Add backwards support for Laravel 8.0 - 8.26.
108
+ // This macro can be removed if we ever deprecate those versions.
109
+ if (! method_exists (ComponentAttributeBag::class, 'class ' )) {
110
+ ComponentAttributeBag::macro ('class ' , function ($ classList ) {
111
+ $ classList = Arr::wrap ($ classList );
112
+
113
+ $ classes = [];
114
+
115
+ foreach ($ classList as $ class => $ constraint ) {
116
+ if (is_numeric ($ class )) {
117
+ $ classes [] = $ constraint ;
118
+ } elseif ($ constraint ) {
119
+ $ classes [] = $ class ;
120
+ }
121
+ }
122
+
123
+ return $ this ->merge (['class ' => implode (' ' , $ classes )]);
124
+ });
125
+ }
105
126
}
106
127
107
128
private function bootRoutes (): void
You can’t perform that action at this time.
0 commit comments