1. Go to this page and download the library: Download zaimealabs/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/ */
zaimealabs / sluggable example snippets
namespace App;
use ZaimeaLabs\Sluggable\HasSlug;
use ZaimeaLabs\Sluggable\SlugOptions;
use Illuminate\Database\Eloquent\Model;
class EloquentModel extends Model
{
use HasSlug;
/**
* Create a new options for generating the slug.
*
* @return \ZaimeaLabs\Sluggable\SlugOptions
*/
public function newSlugOptions(): SlugOptions
{
return SlugOptions::create()
->generateSlugsFrom('name')
->saveSlugsTo('slug');
}
}
/**
* Get the route key for the model.
*/
public function getRouteKeyName(): string
{
return 'slug';
}