Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to skip the slug generation by a condition #227

Merged
merged 2 commits into from
Mar 28, 2022

Conversation

masterix21
Copy link
Contributor

Hi dears.

The PR adds the ability to skip the slug generation by a condition like so:

class Page extends Model
{
        HasSlug;

        public function getSlugOptions(): SlugOptions
        {
            return parent::getSlugOptions()
                ->skipGenerateWhen(fn () => $this->status === 'draft');
        }
}

@freekmurze
Copy link
Member

Very nice, thank you!

@freekmurze freekmurze merged commit e3b102e into spatie:main Mar 28, 2022
@masterix21 masterix21 deleted the feature-skip-generates branch March 28, 2022 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants