belongsToMany(Issue::class, 'issue_label_pivot'); } public function getTextColorAttribute(): string { // Calculate if we should use black or white text based on background color $color = $this->color; $r = hexdec(substr($color, 1, 2)); $g = hexdec(substr($color, 3, 2)); $b = hexdec(substr($color, 5, 2)); // Calculate perceived brightness $brightness = (($r * 299) + ($g * 587) + ($b * 114)) / 1000; return $brightness > 128 ? '#000000' : '#FFFFFF'; } }