Skip to content

Honor pre-set slugs and refine slug generation - #20

Closed
gregupton wants to merge 1 commit into
mainfrom
codex/conduct-code-review
Closed

gregupton wants to merge 1 commit into
mainfrom
codex/conduct-code-review

Conversation

@gregupton

Copy link
Copy Markdown
Contributor

Summary

  • add string type hint to findBySlug
  • skip slug regeneration when a model already has a slug
  • remove default fallback when resolving slug source
  • document manual slug usage and update changelog
  • fix changelog order so version 1.1.5 precedes 1.1.4

Testing

  • php composer.phar install (fails: curl error 56 while downloading https://repo.packagist.org/packages.json: CONNECT tunnel failed, response 403)
  • ./vendor/bin/phpunit (fails: No such file or directory)

https://chatgpt.com/codex/tasks/task_e_68bc5b28e8b4832cbc3e8489d05a7878

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Review: Here are some suggestions.

Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Comment thread src/Traits/Sluggable.php
Comment on lines +62 to +66
// If the slug column already has a value, honor it and skip generation
$slugColumn = $this->getSlugColumn();
if (! empty($this->{$slugColumn})) {
return;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Early return prevents configured slug updates

generateSlug now returns whenever the slug column already has any value (if (! empty($this->{$slugColumn})) { return; }). After the first save every model has a non-empty slug, so this branch executes on every update and the method never reaches the logic that regenerates the slug when slugUpdatable is enabled and the source field is dirty. This regresses existing behaviour and causes tests like it('updates the slug on update') to fail because slugs no longer update when titles change unless the slug attribute is manually cleared.

Useful? React with 👍 / 👎.

@gregupton gregupton closed this Nov 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant