Initial commit

This commit is contained in:
2025-11-20 23:21:05 +08:00
commit 13bc6db529
378 changed files with 54527 additions and 0 deletions

37
app/Models/IssueLabel.php Normal file
View File

@@ -0,0 +1,37 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class IssueLabel extends Model
{
use HasFactory;
protected $fillable = [
'name',
'color',
'description',
];
public function issues(): BelongsToMany
{
return $this->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';
}
}