coolify/app/Models/Tag.php
Andras Bacsai f617e58401 Merge remote-tracking branch 'origin/next' into feat/api/tag-management
# Conflicts:
#	app/Http/Controllers/Api/ApplicationsController.php
2026-07-07 12:49:19 +02:00

46 lines
1,022 B
PHP

<?php
namespace App\Models;
use App\Traits\HasSafeStringAttribute;
use OpenApi\Attributes as OA;
#[OA\Schema(
description: 'Tag model',
type: 'object',
properties: [
new OA\Property(property: 'uuid', type: 'string'),
new OA\Property(property: 'name', type: 'string'),
new OA\Property(property: 'created_at', type: 'string'),
new OA\Property(property: 'updated_at', type: 'string'),
]
)]
class Tag extends BaseModel
{
use HasSafeStringAttribute;
protected $fillable = [
'name',
'team_id',
];
protected function customizeName($value)
{
return strtolower($value);
}
public static function ownedByCurrentTeam()
{
return Tag::whereTeamId(currentTeam()->id)->orderBy('name');
}
public function applications()
{
return $this->morphedByMany(Application::class, 'taggable');
}
public function services()
{
return $this->morphedByMany(Service::class, 'taggable');
}
}