How to Create Slug in Laravel ?

Today we will see how to create slug in laravel.

The Str::slug method generates a URL friendly "slug" from the given string in laravel but before that we need to add string helper use Illuminate\Support\Str;

Complete code.

use Illuminate\Support\Str;

$slug = Str::slug('Laravel Coderuck', '-');

// laravel-coderuck


Leave a reply

your email address will not be published. required fields are marked *

Name *
Email *