Tricks

在 IconColumn 中使用自定义 SVG

Jun 17, 2023
Martin

首先创建一个自定义 Blade 组件,将 SVG 代码写入其中。比如:

resources/views/components/icons/high-score.blade.php

<svg>
...
</svg>

然后使用自定义组件名替换 heroicon- 名:

IconColumn::make('score')
->options([
'icons.high-score' => fn ($state): bool => $state >= 66,
'icons.medium-score' => fn ($state): bool => $state >= 33 && $state < 66,
'icons.low-score' => fn ($state): bool => $state < 33,
]),