Support the ongoing development of Laravel.io →
Input Database Packages
Last updated 1 year ago.
0

Why do something like this:

 Route::get('post/{username}/{post_title}');
Last updated 1 year ago.
0

Are you asking me why? That's what I am doing. That's why the post_title needs to only be unique to the username, not table wide.

Last updated 1 year ago.
0

then every post must be assigned to a single username/user_id

Last updated 1 year ago.
0

If yout think about validating the uniqueness of the username / slug combination, you can pass additional parameters to the unique rule. Thats explained with more details in the docs.

'unique:users,' . $username . ',NULL,id,slug,' . $slug

If its not for validating a form I don't know anyway of doing it except running a query.

And laravel already have a slug generator : Str::slug(); :)

Last updated 1 year ago.
0

laravel already have this helper included with Str facade . try this : Str::slug('your string');

Last updated 1 year ago.
0

My eloquent-sluggable package may be of help. It won't do what you need out of the box, but you could overload the method to check for uniqueness with your own logic, and you should be good to go. Open an issue if you need some more help.

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.