PHP code example of oguzcandemircan / laravel-unique-sluggable

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

    

oguzcandemircan / laravel-unique-sluggable example snippets




namespace App\Models;

...
use OguzcanDemircan\LaravelUniqueSluggable\HasSlug;

class Page extends Model
{
    use HasFactory;
    use HasSlug;
    
    protected $slugSource = 'title';

use App\Models\Page;
use App\Models\Post;

Page::create(['title' => 'Great Title']);
//Slug is great-title
Post::create(['title' => 'Great Title']);
//you get eror

protected $controller [PageController::class, 'show'];