Skip to content
This repository was archived by the owner on Jan 6, 2026. It is now read-only.

Commit 55272eb

Browse files
Extend WithColor trait: add colorMap support with default hex values and update color method for hex initialization.
1 parent f473d52 commit 55272eb

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

app/Concerns/WithColor.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,20 @@ trait WithColor
1010
{
1111
protected array $colors = [];
1212

13+
protected array $colorMap = [
14+
'Yellow' => '#FFFF00',
15+
'Green' => '#00FF00',
16+
'Blue' => '#0000FF',
17+
'Grey' => '#808080',
18+
'White' => '#FFFFFF',
19+
'Gold' => '#FFCF40',
20+
];
21+
1322
protected function color(string $name): Color
1423
{
15-
return $this->colors[$name] ??= Color::firstOrCreate(['title' => $name]);
24+
return $this->colors[$name] ??= Color::firstOrCreate([
25+
'title' => $name,
26+
'hex' => $this->colorMap[$name] ?? '#000000',
27+
]);
1628
}
1729
}

0 commit comments

Comments
 (0)