Download the PHP package laraeast/laravel-sluggable without Composer
On this page you can find all versions of the php package laraeast/laravel-sluggable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download laraeast/laravel-sluggable
More information about laraeast/laravel-sluggable
Files in laraeast/laravel-sluggable
Package laravel-sluggable
Short Description Easy creation of slugs for your Eloquent models in Laravel
License MIT
Informations about the package laravel-sluggable
Eloquent-Sluggable
Easy creation of slugs for your Eloquent models in Laravel.
Background: What is a slug?
A slug is a simplified version of a string, typically URL-friendly. The act of "slugging" a string usually involves converting it to one case, and removing any non-URL-friendly characters (spaces, accented letters, ampersands, etc.). The resulting string can then be used as an identifier for a particular resource.
For example, if you have a blog with posts, you could refer to each post via the ID:
http://example.com/post/1
http://example.com/post/2
... but that's not particularly friendly (especially for SEO). You probably would prefer to use the post's title in the URL, if your post is titled "My Dinner With Ahmed & Omar", the URL will be:
Installation
-
Install the package via Composer:
-
For Laravel 5.2 >= 6.x
- For Laravel 7.x
The package will automatically register its service provider.
-
Middleware
You should add SluggableRedirectMiddleware
to web
middileware to redirect to latest updated slug.
app/Http/Kernel.php
file :
Updating your Eloquent Models
Your models should use the Sluggable trait, which has an abstract method sluggableFields()
that you need to define. This is where any model-specific configuration is set