PHP code example of amdad121 / unique-slug-laravel

1. Go to this page and download the library: Download amdad121/unique-slug-laravel 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/ */

    

amdad121 / unique-slug-laravel example snippets


namespace App\Models;

use AmdadulHaq\UniqueSlug\HasSlug;
// ...

class User extends Authenticatable
{
    use HasSlug;

    // Optionally you can configure
    public function getSlugSourceAttribute(): string
    {
        return 'name'; // Default attribute to generate slug from
    }

    public function getSlugAttribute(): string
    {
        return 'slug'; // Default attribute to store the slug
    }

    public function getSlugSeparator(): string
    {
        return '-'; // Default separator for the slug
    }
}