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 44
55namespace Rawilk \FormComponents ;
66
7+ use Illuminate \Support \Arr ;
78use Illuminate \Support \Facades \Blade ;
89use Illuminate \Support \Facades \Route ;
910use Illuminate \Support \ServiceProvider ;
@@ -102,6 +103,26 @@ private function bootMacros(): void
102103 ComponentAttributeBag::macro ('hasStartsWith ' , function ($ key ) {
103104 return (bool ) $ this ->whereStartsWith ($ key )->first ();
104105 });
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+ }
105126 }
106127
107128 private function bootRoutes (): void
You can’t perform that action at this time.
0 commit comments