Today now in this post i will show you How to create URL Slug in Laravel? In Generally we need to create the slug when we are work for frontend application by using laravel, here i mean that as like shopping website, social website or blogging website because we need to use slug URL for the post. So, in Laravel provides us several string helper as like as str_limit, str_plural, str_finish, str_singular etc and also can use str_slug().
For generate url slug with laravel 6, laravel 7 and laravel 8 version.
by using str_slug() we can make the proper slug like remove space, remove special character etc. on that way it also good for SEO friendly URL. we can see here i will give you syntax and example of str_slug() helper.
Str::slug(string) OR str_slug(string);
$mySlug = Str::slug('Codings point provide laravel examples'); print_r($mySlug);
$mySlug = str_slug('Codings point provide laravel examples'); print_r($mySlug);
Read Also : How to Create Custom Blade Directive in Laravel?
Thanks for read. I hope it help you. For more you can follow us on facebook.