PHP code example of roundly-consulting / sluggable-for-laravel

1. Go to this page and download the library: Download roundly-consulting/sluggable-for-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/ */

    

roundly-consulting / sluggable-for-laravel example snippets


use Illuminate\Database\Eloquent\Model;
use RoundlyConsulting\Sluggable\Concerns\HasSlug;
use RoundlyConsulting\Sluggable\Contracts\Sluggable;

final class Clinic extends Model implements Sluggable
{
    use HasSlug;

    protected $fillable = ['name', 'slug'];
}

// in the migration
$table->slug();          // string('slug', 255)
$table->uniqueSlug();    // its unique index

use RoundlyConsulting\Sluggable\Facades\Slugs;

Clinic::create(['name' => 'Happy Paws'])->slug;      // "happy-paws"
Clinic::create(['name' => 'Happy Paws'])->slug;      // "happy-paws-2"

Route::get('/clinics/{clinic:slug}', ShowClinic::class);

Slugs::regenerate($clinic);                          // recompute from the new name and save
Slugs::slugify('Žltý kôň @ home', language: 'sk');   // "zlty-kon-at-home"