1. Go to this page and download the library: Download namest/sluggable library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
class User extends Model
{
use \Namest\Sluggable\HasSlug;
// ...
}
$post->slug = 'the-new-post';
$post->save(); // Save post & slug;
$slug = $post->slug; // Get slug string
Slug::isValid($name); // Check a name is valid for slug: unique & sluged
Slug::regenerate($name); // Regenerate a slug if its invalid
Slug::regenerate($name, true); // Regenerate a slug without check its valid or not