Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Doctrine Behaviors Laravel Package

knplabs/doctrine-behaviors

View on GitHub
Deep Wiki
Context7

Sluggable

Sluggable generates slugs (uniqueness is not guaranteed) for an entity.

Will automatically generate on update/persist (you can disable the on update generation by overriding shouldRegenerateSlugOnUpdate() to return false.

You can also override the slug delimiter from the default - by overriding getSlugDelimiter() method.

Slug generation algo can be changed by overriding generateSlugValue().

Use cases include SEO (i.e. URLs like http://example.com/post/3/introduction-to-php)

<?php

declare(strict_types=1);

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Contract\Entity\SluggableInterface;
use Knp\DoctrineBehaviors\Model\Sluggable\SluggableTrait;

/**
 * [@ORM](https://github.com/ORM)\Entity
 */
class BlogPost implements SluggableInterface
{
    use SluggableTrait;

    /**
     * [@ORM](https://github.com/ORM)\Column(type="string")
     * [@var](https://github.com/var) string
     */
    private $title;

    /**
     * [@return](https://github.com/return) string[]
     */
    public function getSluggableFields(): array
    {
        return ['title'];
    }

    public function generateSlugValue($values): string
    {
        return implode('-', $values);
    }
}
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log
hsluv/hsluv
seampact/codegen
seampact/hooks
seampact/ir
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk