Skip to content

Commit 6665b4e

Browse files
committed
fix(Taxonomy): include type in DuplicateSlugException for better error context
1 parent defd29b commit 6665b4e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Models/Taxonomy.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ protected static function boot(): void
112112

113113
// If slug is provided, check if it's unique within the same type
114114
if (! empty($taxonomy->slug) && static::slugExists($taxonomy->slug, $taxonomy->type, null)) {
115-
throw new DuplicateSlugException($taxonomy->slug);
115+
throw new DuplicateSlugException($taxonomy->slug, $taxonomy->type);
116116
}
117117

118118
// Set nested set values for new taxonomy
@@ -123,7 +123,7 @@ protected static function boot(): void
123123
// If slug is being changed manually, check if it's unique within the same type
124124
if ($taxonomy->isDirty('slug') && ! empty($taxonomy->slug)) {
125125
if (static::slugExists($taxonomy->slug, $taxonomy->type, $taxonomy->id)) {
126-
throw new DuplicateSlugException($taxonomy->slug);
126+
throw new DuplicateSlugException($taxonomy->slug, $taxonomy->type);
127127
}
128128
}
129129

@@ -389,7 +389,7 @@ public static function createOrUpdate(array $attributes): self
389389
} else {
390390
// If a custom slug is provided, check if it's unique within the same type
391391
if (isset($attributes['slug']) && static::slugExists($attributes['slug'], $attributes['type'])) {
392-
throw new DuplicateSlugException($attributes['slug']);
392+
throw new DuplicateSlugException($attributes['slug'], $attributes['type']);
393393
}
394394

395395
// If not found, ensure the slug is unique before creating

0 commit comments

Comments
 (0)