<?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"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.