1. Go to this page and download the library: Download fomvasss/laravel-slugmaker 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/ */
fomvasss / laravel-slugmaker example snippets
public function slug()
{
return $this->morphOne(\Fomvasss\SlugMaker\Models\Slug::class, 'slugable');
}
namespace App\Models;
use Fomvasss\SlugMaker\ModelHasSlug;
use Illuminate\Database\Eloquent\Model;
class Article extends Model
{
use ModelHasSlug;
protected $with = ['slug'];
/**
* Get the default fields for generating the slug.
*/
public function getSlugSourceFields()
{
return ['id', 'name', 'created_at']; // "124-article-test-slug-2017-12-26-135705"
}
}