mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-12 22:14:26 +00:00
feat(api): add tags to resource creation
Normalize tag names before attaching them, reject names that are too short after sanitization, and return 404 when removing tags not attached to the resource. Adds a per-team unique tag-name index and migrates duplicate tags onto the kept record before creating the constraint.
This commit is contained in:
1 parent
f617e58401
commit
11b35ba3c1
12 files changed
+1466
-80
No files matched your search
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\HasSafeStringAttribute;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use OpenApi\Attributes as OA;
|
||||
|
||||
#[OA\Schema(
|
||||
@@ -34,6 +35,13 @@ class Tag extends BaseModel
|
||||
return Tag::whereTeamId(currentTeam()->id)->orderBy('name');
|
||||
}
|
||||
|
||||
public function deleteIfOrphaned(): void
|
||||
{
|
||||
if (DB::table('taggables')->where('tag_id', $this->id)->doesntExist()) {
|
||||
$this->delete();
|
||||
}
|
||||
}
|
||||
|
||||
public function applications()
|
||||
{
|
||||
return $this->morphedByMany(Application::class, 'taggable');
|
||||
|
||||
Reference in new issue
Block a user