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

Slugging does not occur If the sluggable field and the source are the same #270

Closed
shadoWalker89 opened this issue Jun 7, 2016 · 5 comments

Comments

@shadoWalker89
Copy link

Hi,

Slugging does not occur If the sluggable field and the source are the same

@cviebrock
Copy link
Owner

Nor should it, I would think. How would that work?

@shadoWalker89
Copy link
Author

I have a form field for the slug. In my case the slug is not derived from another field but the value of the slug field it self in the form is the one being slugged.

In my project i have a pages module where the user will specify the uri of the page using the slug field.

The user can say something like "contact us" and it should be transformed to "contact-us"

I think you shouldn't make such restrictions and let the user choose decide freely what is the source field.

@cviebrock
Copy link
Owner

I get what you're trying to do. But then I don't think this package is what you need.

My idea was to make it easy to automatically generate slugs based on other fields in the model (e.g. generate the URI from the page's title field, etc.). What you are discussing is having users manually specify the field ... in which case you can get away with Laravel's built in validation rules to ensure uniqueness, and built in functions like Str::slug to make the strings URI-friendly.

If you can submit a PR that allows the source field for a slug to be the same as the destination field, and some related tests, I'd be happy to consider it. But I do feel that what you are asking is outside the scope of this package.

@shadoWalker89
Copy link
Author

@cviebrock My table, model have a field called "slug". I am actually saving the slug into the database.
So this shouldn't make any difference for you.

The only difference in my case, is that i'm using the same field for the source and destination instead of using the title field.
If i make another field and call it "slug_raw" and use it as a source for the "slug" field in my model things will work again. But this is not a clean way to go about it.

By the way i'm using you package in my articles module where i have the title as the source for the slug.
But in my pages module, i wanted to have the possibility to have the title different from the slug, and that is why i have a slug field on my form.

@jordanade
Copy link

Would be useful for me too. The main use for me is the checking existing slugs and generating unique ones. In my case I don't actually want to store the source string at all.

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

No branches or pull requests

3 participants