actengage / sluggable
A simple trait to ensure Laravel models have slugs.
Installs: 1 167
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 2
Requires
- php: ^8.2
- laravel/framework: ^11.0
Requires (Dev)
- mockery/mockery: ^1.1
- orchestra/testbench: ^9.0
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2025-01-11 19:09:23 UTC
README
A simple package for managing "slugs" to Eloquent models. Sluggable is a trait for Eloquent models to ensure a slug exists for the model, and saved it in a column
Installation
composer require actengage/sluggable
Implementation
To implement Sluggable, you just need to assign the Sluggable
trait to the
model.
namespace App\Page;
use Actenage\Sluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;
class Page extends Model {
use Sluggable;
protected $fillable = [
'title', 'slug'
];
}
Basic Example
$page = Page::create([
'title' => 'This is some title'
]);
dd($page->slug); // 'this-is-some-page-title'