Image

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

 

Categories: PHP Tags: #Laravel,

Newsletter Subcribe

Receive updates and latest news direct from our team. Simply enter your email.