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

feat: add findBySlug alias #256

Merged
merged 2 commits into from
May 29, 2023
Merged

feat: add findBySlug alias #256

merged 2 commits into from
May 29, 2023

Conversation

IsraelOrtuno
Copy link
Contributor

@IsraelOrtuno IsraelOrtuno commented May 24, 2023

I have added a convenient method findBySlug to retrieve a model by the saveSlugsTo field configured in the SlugOptions. Works on both HasSlug and HasTranslatableSlug.

@freekmurze freekmurze merged commit ddfb38d into spatie:main May 29, 2023
@freekmurze
Copy link
Member

Thank you!

@francoism90
Copy link

@IsraelOrtuno It would be great if you could introduce findBySlugOrFail as well. :)

I've done this before for the prefixed-id package, and it's really helpful when binding this as router parameters.

@IsraelOrtuno
Copy link
Contributor Author

@IsraelOrtuno It would be great if you could introduce findBySlugOrFail as well. :)

I've done this before for the prefixed-id package, and it's really helpful when binding this as router parameters.

@francoism90 it's indeed useful. Would be interesting to add a whereSlug scope so we could add findBySlug and findBySlugOrFail based on the scope.

Will check on this when I have more time.

@francoism90 francoism90 mentioned this pull request Jun 22, 2023
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.

3 participants