瀏覽代碼

Add polyfill for HasIconPosition trait to support older Filament versions

3.x
Amirul Anwar 9 小時之前
父節點
當前提交
8a440366a5
共有 2 個檔案被更改,包括 36 行新增2 行删除
  1. 33
    0
      app/Support/Polyfills/Filament/Concerns/HasIconPosition.php
  2. 3
    2
      composer.json

+ 33
- 0
app/Support/Polyfills/Filament/Concerns/HasIconPosition.php 查看文件

@@ -0,0 +1,33 @@
1
+<?php
2
+
3
+namespace Filament\Support\Concerns;
4
+
5
+/**
6
+ * Polyfill for Filament Support HasIconPosition trait for older Filament versions.
7
+ * If the real trait exists in the installed Filament version, Composer will still load this file
8
+ * but PHP will prefer the original trait if namespaced identically when loaded earlier.
9
+ */
10
+if (! trait_exists(\Filament\Support\Concerns\HasIconPosition::class)) {
11
+    trait HasIconPosition
12
+    {
13
+        /**
14
+         * Can be 'before' | 'after' | mixed depending on Filament version.
15
+         */
16
+        protected $iconPosition = null;
17
+
18
+        /**
19
+         * @param  IconPosition|callable|string|null  $position
20
+         */
21
+        public function iconPosition($position): static
22
+        {
23
+            $this->iconPosition = $position instanceof \Closure ? $position($this) : $position;
24
+
25
+            return $this;
26
+        }
27
+
28
+        public function getIconPosition()
29
+        {
30
+            return $this->iconPosition ?? 'before';
31
+        }
32
+    }
33
+}

+ 3
- 2
composer.json 查看文件

@@ -20,7 +20,7 @@
20 20
         "barryvdh/laravel-snappy": "^1.0",
21 21
         "codewithdennis/filament-simple-alert": "^3.0",
22 22
         "fakerphp/faker": "^1.24",
23
-        "filament/filament": "^3.2",
23
+    "filament/filament": "^3.2",
24 24
         "guava/filament-clusters": "^1.1",
25 25
         "jaocero/radio-deck": "^1.2",
26 26
         "laravel/framework": "^12.0",
@@ -49,7 +49,8 @@
49 49
             "Database\\Seeders\\": "database/seeders/"
50 50
         },
51 51
         "files": [
52
-            "app/Helpers/helpers.php"
52
+            "app/Helpers/helpers.php",
53
+            "app/Support/Polyfills/Filament/Concerns/HasIconPosition.php"
53 54
         ]
54 55
     },
55 56
     "autoload-dev": {

Loading…
取消
儲存