Laravel, Unicode'u transliterasyon yapan ve bir dil argümanı destekleyen Str::slug() yardımcısıyla slugları zahmetsiz kılar. Veritabanı modelleri için, bir çakışma tespit edildiğinde kısa rastgele bir sonek ekleyerek benzersiz bir slug oluşturun.
use Illuminate\Support\Str;
$slug = Str::slug('Merhaba Dünya', '-'); // merhaba-dunya
// Guarantee a unique slug for a model
$slug = $base = Str::slug($request->title);
while (Post::where('slug', $slug)->exists()) {
$slug = $base . '-' . Str::random(5);
}