PHP code example of pawelmysior / laravel-sluggable

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

    

pawelmysior / laravel-sluggable example snippets



 
namespace App;
  
use Illuminate\Database\Eloquent\Model;
use PawelMysior\Sluggable\Sluggable;
 
class Post extends Model
{
    use Sluggable;
}


 
namespace App;
  
use Illuminate\Database\Eloquent\Model;
use PawelMysior\Sluggable\Sluggable;
 
class Post extends Model
{
    use Sluggable;

    protected function getSlugSourceAttribute(): string
    {
        return $this->name;
    }
}

Post::findBySlug('slug');