1. Go to this page and download the library: Download oleaass/laravel-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/ */
oleaass / laravel-sluggable example snippets
namespace App\Models;
use OleAass\Sluggable\Sluggable;
class Post extends Model
{
use Sluggable;
public function getSlugOptions() : array
{
return [
'source' => 'title'
];
}
}
[
'source' => 'title', // The field used as source for the slug
'dest' => 'slug', // Name of the slug column
'onCreate' => true, // If true, automatically create slug when creating a new resource
'onUpdate' => false, // If true, automatically change slug when updating an existing resource
'allowOverwrite' => true, // If true, overwrite existing slug when updating a resource
'allowDuplicate' => false, // If true, non unique slugs can be created (recommended to be false always)
'delimiter' => '-', // Replace spaces with this
];
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.